开发者

Preferred kind of array for storing iPhone favorite items?

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]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜