开发者

Best Way To Keep A User-Modified List Of Application Names

I'm looking for th开发者_开发百科e best way to deal with a modifiable list of application names in an app's "Preferences" to be used as a filter.

I'd like to be able to have a few defaults in this on first run, and for the user to be able to modify this array.

So what's the best way to create and store a default array of Application Names (or anything, really) that can be modified and saved as a preference by a user?

NSArray saved somewhere? A really long entry in my defaults.plist?


If you just want to store an array of strings, the quickest and simplest way to do that is using NSUserdefaults. Very very easy to use.

-(void)saveToUserDefaults:(NSString*)myString
{
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

    if (standardUserDefaults) {
        [standardUserDefaults setObject:myArray forKey:@"StoredArray"];
        [standardUserDefaults synchronize];
    }
 }


 -(void)retrieveFromUserDefaults
{
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    NSArray *myArray = nil;

    if (standardUserDefaults) 
        val = [standardUserDefaults objectForKey:@"StoredArray"];

    //do something with your array
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜