I am using the following array to add an object that was previously created to the favo开发者_开发百科rite array:
NSMutableArray *favorites = [NSMutableArray addObject:[myList objectAtIndex:1]];
However, this code keeps crashing at runtime. I think this is not the best way to implement an array that can save and delete items; is there a better way to implement this? Is there a way to automate this process without having to add an array for every cell selected from the table?
Just write (assuming favorites array have already been created):
[favorites addObject:[myList objectAtIndex:1]];
To create new array you should use for example +arrayWithObject:
NSMutableArray *favorites = [NSMutableArray arrayWithObject:[myList objectAtIndex:1]];
精彩评论