NSUserDefaults的小封装
//保存
-(void)saveToUserDefaults:(NSString*)tosaveedString withKey:(NSString *)tosaveedKey
{
NSUserDefaults * tmp = [NSUserDefaults standardUserDefaults];
if (tmp) {
[tmp setObject:tosaveedString forKey:tosaveedKey];
[tmp synchronize];
}
}
//取出
-(NSString *)restoreFromUserDefaults:(NSString *)key
{
NSString * rtn = nil;
NSUserDefaults * tmp = [NSUserDefaults standardUserDefaults];
if (tmp) {
rtn = [tmp objectForKey:key];
}
return rtn;
}
//可以把上面的方法写成类方法