Issue
I have set a bool value for key TCshow in my NSUserDefault, I want to run a nslog test whether the key is saved or not, and i m trying to printout the bool value. here is my code but it s not working, any suggestions?
- (IBAction)acceptAction:(id)sender {
//key store to nsuserdefault
self.storedKey = [[NSUserDefaults alloc] init];
[self.storedKey setBool:YES forKey:@"TCshow"];
//trying to print out yes or not, but not working...
NSLog(@"%@", [self.storedKey boolForKey:@"TCshow"]);
}
Solution
%@
is for objects. BOOL
is not an object. You should use %d
.
It will print out 0
for FALSE/NO and 1
for TRUE/YES.
Answered By - Peter Warbo Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.