NSUserDefault exists -iPHONE SDK

How would I check in a "if" statement if the NSUserDefault object is saved there or not? I'm not really sure how to call it.. So a pretty short question..

Thanks

Answers


if ([[NSUserDefaults standardUserDefaults] objectForKey:@"Foo"] != nil) {
  NSLog(@"an object is saved under \"Foo\"!");
}

Dave's answer is correct, but I'd skip the explicit test for nil:

if ([[NSUserDefaults standardUserDefaults] objectForKey:@"Foo"]) {
    NSLog(@"An object is saved under \"Foo\"!");
}

Need Your Help

posts_per_page is displaying 2 less items than intended

php wordpress

my first question here, so I'm sorry if I do something wrong :S

SwingUtilities.windowForComponent(JFrame) returns null

java swing jframe swingutilities

frame is the only JFrame in my Swing app. Since JFrame extends Window I have believed from description and method name that the code should return the frame itself.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.