我要将NSUserDefault的值保存到Array中,稍后必须POST值 请使用HTTP POST,m尝试此代码,其工作正常(当我重新打开我的应用程序值重新出现在屏幕上)但是当我输入tte值....它显示userneme = null,database = null .....)我应该怎么做。我应该将NSUserDefault的值保存到数组然后POST ,,,, plz帮助我.....代码将被appcaciated ... Thanx in Advance
[NSUserDefaults resetStandardUserDefaults];
NSUserDefaults *storeData = [NSUserDefaults standardUserDefaults];
[storeData setObject:utextFieldNormal.text forKey:@"username"];
[storeData setObject:urltextFieldNormal.text forKey:@"url"];
[storeData setObject:dtextFieldNormal.text forKey:@"database"];
[storeData setObject:utextFieldNormal.text forKey:@"username"];
[storeData setObject:urltextFieldNormal.text forKey:@"url"];
[storeData setObject:dtextFieldNormal.text forKey:@"database"];
NSString *val1= [storeData valueForKey:@"username "];
NSString *val2= [storeData valueForKey:@"url"];
NSString *val3= [storeData valueForKey:@"database "];
//NSLog(@"username:%@",username);
NSLog(@"username:%@",val1);
NSLog(@"url:%@",val2);
NSLog(@"database:%@",val3);
[storeData synchronize];
答案 0 :(得分:1)
这是实际的代码复制/粘贴吗?传递给valueForkey的键字符串在末尾有额外的空格。删除空格,它会正常工作。