开发者

question on NSUserDefault Class

开发者 https://www.devze.com 2023-01-02 18:05 出处:网络
I have value in 1 string for particular key. but NSUserDefault class method doesn\'t work properly and it doesn\'t set object of a string forkey .开发者_StackOverflow

I have value in 1 string for particular key. but NSUserDefault class method doesn't work properly and it doesn't set object of a string forkey .开发者_StackOverflow

in short setobject forkey method is not working of NSUserDefault class. why is it so?


First of all, NSUserDefault class works just fine. It is called millions of times every day and works exactly as expected. The next likely culprit is your code. If you post that, it will be much easier to determine what you're doing wrong, and to make an appropriate suggestion.

(Edit added after OP's comment)

I just added this code:

//* TEST
NSString *string01 = @"Hardwork";
NSUserDefaults* defs111 = [NSUserDefaults standardUserDefaults];
[defs111 setObject:string01 forKey:@"first_name_textfield"];
NSString *test = [defs111 objectForKey:@"first_name_textfield"];
NSLog(@"Test: %@", test);

to my project and ran it and everything worked just fine.

As I stated above: NSUserDefault works like a champ. There's something you're not telling us about your use-case. Something important. ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号