那我就不知道为什么了,我没有你用的那么复杂,我把我的用法贴出来给你看看

+(void)saveUser:(NSString *)account userID:(int)UserID passwd:(NSString *)passwd
{
    [UD setObject:@{@"account" : account, @"userID":[@(UserID) stringValue], @"passwd" : passwd} forKey:@"loginInfo"];
    [UD synchronize];
}取
+(NSString *) account
{
    return [[UD objectForKey:@"loginInfo"] valueForKey:@"account"];
}就这样就行了

解决方案 »

  1.   

    http://www.cnblogs.com/letmefly/archive/2012/07/14/2591735.html
    不知这篇文章能不能解决你的疑惑
      

  2.   

        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
        
        //注册默认设置
        NSDictionary *defaultValues = [NSDictionary dictionaryWithObjectsAndKeys: [[NSNumber alloc] initWithBool:NO], @"currency", [[NSNumber alloc] initWithBool:YES], @"dailyNotification", nil];
        [userDefaults registerDefaults:defaultValues];
        
        [userDefaults setValue:[[NSNumber alloc] initWithInt:0] forKey:@"dailyNotification"];
        BOOL flag = [userDefaults boolForKey:@"dailyNotification"];
        
        NSLog(@"flag = %d", flag);
        [userDefaults removeObjectForKey:@"dailyNotification"];
        flag = [userDefaults boolForKey:@"dailyNotification"];
        
        NSLog(@"flag = %d", flag);你的代码:
    NSDictionary *defaultValues = [NSDictionary dictionaryWithObjectsAndKeys:0,@"currency",YES,@"dailyNotification", nil];
        [userDefaults registerDefaults:defaultValues];实际就是:
    NSDictionary *defaultValues = [NSDictionary dictionaryWithObjectsAndKeys:0];
        [userDefaults registerDefaults:defaultValues];NSDictionary dictionaryWithObjectsAndKeys需要的参数是对象,这个时候,0与nil是等价的。