I have a function get information. I debug and get true information. But when i run app it make error:
 App[2055:59870] Attempt to set a non-property-list object null as an NSUserDefaults/CFPreferences value for key lastName
My function check login and get information:
        NSString *password = _txtPass.text;
        NSData *passwordData = [password dataUsingEncoding:NSUTF8StringEncoding];
        NSString *passwordMD5 = [functionStr MD5:passwordData];
        NSString *userUrl = [NSString stringWithFormat:@"http://ios.khothe.vn/web/gamecard/authenticate/user/%@/pass/%@", _txtUser.text, passwordMD5];
        //NSLog(@"link: %@", userUrl);
        NSURL *url = [NSURL URLWithString:userUrl];
        NSURLRequest *request=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30.0];
        //get data
        /*NSError *error= [[NSError alloc] init];
         NSHTTPURLResponse *response;
         NSData *data= [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];*/
        NSError *error = nil;
        NSHTTPURLResponse *response;
        NSData *data= [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
        if (!data) {
            NSLog(@"Error: %@", [error localizedDescription]);                
        }
        //NSLog(@"Response code: %ld", (long)[response statusCode]);
        if([response statusCode]>=200 && [response statusCode]<300){
            //bug du lieu nhan dc
            //NSString *responseData= [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
            //NSLog(@"Data nhận đc: %@", responseData);
            NSError *error= nil;
            NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
            success = [[jsonDictionary valueForKey:@"success"] integerValue];
            if(success == 400){
                NSString *currency;
                if([[jsonDictionary valueForKey:@"country"]isEqualToString:@"36"]){
                    currency = @"AUD";
                }else if([[jsonDictionary valueForKey:@"country"]isEqualToString:@"704"]){
                    currency = @"VND";
                }else{
                    currency = @"USD";
                }                    
                NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
                [defaults setObject:[jsonDictionary valueForKey:@"username"] forKey:@"userName"];
                [defaults setObject:[jsonDictionary valueForKey:@"display_name"] forKey:@"displayName"];
                [defaults setObject:[jsonDictionary valueForKey:@"email"] forKey:@"email"];
                [defaults setObject:[jsonDictionary valueForKey:@"first_name"] forKey:@"firstName"];
                [defaults setObject:[jsonDictionary valueForKey:@"last_name"] forKey:@"lastName"];
                [defaults setObject:[jsonDictionary valueForKey:@"street1"] forKey:@"street"];
                [defaults setObject:[jsonDictionary valueForKey:@"postal_code"] forKey:@"postCode"];
                //[defaults setObject:[jsonDictionary valueForKey:@"rating"] forKey:@"rating"];
                [defaults setObject:currency forKey:@"currency"];
                [defaults synchronize];
            }else{
                [self showUIAlertWithMessage:@"Error! Please wrong username or password" andTitle:@"Message"];
            }
        }
    }
I hope this is enough code to give you an idea o what I am trying to do. lease help me fix my function. Thanks you!