How to save NSMutablearray in NSUserDefaults

Note: NSUserDefaults will always return an immutable version of the object you pass in. To store the information: // Get the standardUserDefaults object, store your UITableView data array against a key, synchronize the defaults NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; [userDefaults setObject:arrayOfImage forKey:@”tableViewDataImage”]; [userDefaults setObject:arrayOfText forKey:@”tableViewDataText”]; [userDefaults synchronize]; To retrieve the information: NSUserDefaults *userDefaults = [NSUserDefaults … Read more

Objective-C Simplest way to create comma separated string from an array of objects

Use the NSArray instance method componentsJoinedByString:. In Objective-C: – (NSString *)componentsJoinedByString:(NSString *)separator In Swift: func componentsJoinedByString(separator: String) -> String Example: In Objective-C: NSString *joinedComponents = [array componentsJoinedByString:@”,”]; In Swift: let joinedComponents = array.joined(seperator: “,”)

NSMutableArray – force the array to hold specific object type only

Update in 2015 This answer was first written in early 2011 and began: What we really want is parametric polymorphism so you could declare, say, NSMutableArray<NSString>; but alas such is not available. In 2015 Apple apparently changed this with the introduction of “lightweight generics” into Objective-C and now you can declare: NSMutableArray<NSString *> *onlyStrings = … Read more

‘Invalid update: invalid number of rows in section 0

You need to remove the object from your data array before you call deleteRowsAtIndexPaths:withRowAnimation:. So, your code should look like this: // Editing of rows is enabled – (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { //when delete is tapped [currentCart removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } } You can also simplify … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)