NSUserDefaults的使用

NSUserDefaults *store = [NSUserDefaults standardUserDefaults];	
NSUInteger selectedIndex = 1;
[store setInteger:selectedIndex forKey:@"selectedIndex"];
	
if ([store valueForKey:@"selectedIndex"] != nil) {
   NSInteger index = [store integerForKey:@"selectedIndex"];		
   NSLog(@"用户已经设置的selectedIndex的值是:%d", index);
} else {		
   NSLog(@"请设置默认的值");		
}

 

你可能感兴趣的:(NSUserDefaults)