开发者

Preferred kind of array for storing iPhone favorite items?

开发者 https://www.devze.com 2023-01-12 06:10 出处:网络
I am using the following array to add an object that was previously created to the favo开发者_开发百科rite array:

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

精彩评论

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