//存
NSString * adate = @"if you see me ,Congratulations,you are success!";
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"adate:%@",adate);
[defaults setObject:adate forKey:@"adate"];
[defaults synchronize]; //缺少了,存不进去的
//取
NSUserDefaults * _defaults = [NSUserDefaults standardUserDefaults];
NSString * _adate;
_adate = [_defaults objectForKey:@"adate"];
NSLog(@"_adate:%@",_adate);
NSUserDefaults存储的位置: /Users/*****/Library/Application Support/iPhone Simulator/4.1/Applications/29788E40-AF47-45A0-8E92–3AC0F501B7F4/,(这个是应用程序对应在mac上的位置)
这个下面有/Library/Prefereces,里面有个plist文件,存储的就是你的userDefaults.
想要删掉的话,用removeObjectForKey或者删掉沙盒,也就是你的应用程序然后重新安装。