开发者

NSArray to plist to TableView

开发者 https://www.devze.com 2023-02-23 13:56 出处:网络
Thanks in advance. I create an array with 6 parts, each an NSString in one of my views. Each string is taken from a U开发者_运维百科ITextField. I want to make a save button that saves the Array into a

Thanks in advance. I create an array with 6 parts, each an NSString in one of my views. Each string is taken from a U开发者_运维百科ITextField. I want to make a save button that saves the Array into a plist. I then want a TableView to display a table sorted by the first object in the array, the first string.

I've created a blank plist with the name I want and named the plist the same thing as the array. Frankly, I'm lost after that. I don't understand if what I'm making is a dictionary in the plist or an array, and how to do it.

Once the table is made, I think I can handle pushing new views from the selected row.

Anything would help. Thanks and stack overflow has been really helpful.

Thanks again.


If you are really set on using files, to this to write an array to your .plist:

NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:theArray forKey:yourKey];
[dictionary writeToFile:@"/somepath/blah.plist" atomically:YES];
[dictionary release];

This will set the root of your .plist file to be a NSDictionary. If you want it to be an NSMutableArray just change the class of the *dictionary.

Answer via: primary source


To store data it's better to use NSUserDefaults and not files because reading and writing it it's much easier. There is a primer at: Primer link

0

精彩评论

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

关注公众号