On Nov 12, 2010, at 10:16, Quincey Morris wrote:

> - (id) valueForUndefinedKey: (NSString*) key {
>       id retVal=[properties objectForKey:key]; // note: NOT 'valueForKey:'
>       if (!retVal) {
>               //fetch value from network
>               //We do not wait for the value
>       }
>       return retVal;
> }

Oops, sorry, I meant to suggest a slightly different implementation, but 
forgot. Here's what I had in mind:

static NSSet* knownKeys = [NSSet setWithObjects: ... list of 82 keys your 
dictionary is allowed to contain ..., nil];

- (id) valueForUndefinedKey: (NSString*) key {

        if (![knownKeys containsObject: key])
                return [super valueForUndefinedKey: key];

        id retVal=[properties objectForKey:key]; // note: NOT 'valueForKey:'
        if (!retVal) {
                //fetch value from network
                //We do not wait for the value
        }
        return retVal;
}

Alternatively, you could prefill your dictionary with [NSNull null] values for 
all keys, and test for that instead.

That way you can tell the difference between an invalid key and a key that 
hasn't been fetched yet.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to