User Tools

Site Tools


ios:study-note

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revisionBoth sides next revision
ios:study-note [2012/09/07 20:34] – created percyios:study-note [2012/09/07 20:37] percy
Line 1: Line 1:
 +
 ====== iOS学习笔记 ====== ====== iOS学习笔记 ======
 +
 +===== NSUserDefaults =====
 +<code>
 +    NSString *setting=[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
 +    if (!setting) {
 +        return;
 +    }
 +    
 +    NSDictionary *dictionary=[NSDictionary dictionaryWithContentsOfFile:[setting stringByAppendingPathComponent:@"Root.plist"]];
 +    NSArray *array = [dictionary objectForKey:@"PreferenceSpecifiers"];
 +    NSMutableDictionary *registerToDefault=[NSMutableDictionary dictionaryWithCapacity:[array count]];
 +    for (NSDictionary *item in array) {
 +         NSString *key = [item objectForKey:@"Key"];
 +        if (key) {
 +            [registerToDefault setObject:[item objectForKey:@"DefaultValue"] forKey:@"DefaultValue"];
 +            break;
 +        }
 +    }
 +    
 +    [[NSUserDefaults standardUserDefaults] registerDefaults:registerToDefault];
 +</code>
 +<code>
 + NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
 +    NSString *title = [userDefault objectForKey:@"title_preference"];
 +
 +</code>
  
/var/www/dokuwiki/wiki/data/pages/ios/study-note.txt · Last modified: 2016/05/05 13:07 by 127.0.0.1