Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: how do I check the defaults for an object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do I check the defaults for an object?




On May 27, 2006, at 12:17 PM, Alan Smith wrote:

Hey,
I need to get an array from UserDefaults but the first time this app
is run there won't be that array. That's not the only time either. So,
I need to check to see if that array exists so the app doesn't crash,
the way it does now. I've tried this:

if ([[NSUserDefaults standardUserDefaults] objectForKey:[[otherTable
selectedPilot] name]])
{
      //Code creating the array
}

Your code appears to be backwards - the "code creating the array" will be hit if the object already exists (and if it doesn't exist, it appears that it may never get created).


Not sure if that's your entire problem - the easiest way is to break when the exception is thrown and see exactly where in your code some parent of it came from...

Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >how do I check the defaults for an object? (From: "Alan Smith" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.