I have what looks like an odd race condition surrounding my bindings. I have an NSCollectionView that is a list of images. I believe all of the bindings to be hooked up correctly (and code-reviewed by 2 other engineers familiar with NSCollectionViews.)

Some code snippets:

        ---

@implementation AppController

-(void)awakeFromNib {
    NSLog(@"AppController::awakeFromNib");

        [...]

    pictureListController = [[PictureListController alloc] init];
    [pictureListController showWindow:nil];

        ---

@implementation PictureListController

@synthesize imagesArray;        // @property(nonatomic, retain)

- (id)init {
//    self = [super init];
//    [self setImagesArray:[NSArray array]];
    [self adjustPictureArray];
    NSLog(@"[DEBUG] about to initWithWindowNibName:@PictureList");
    [self initWithWindowNibName:@"PictureList"];
    NSLog(@"[DEBUG] AFTER initWithWindowNibName:@PictureList");

    return self;
}

    [...]

#define KEY_KEY     @"KEY"
#define IMAGE_KEY   @"IMAGE"
- (void)adjustPictureArray {
    NSLog(@"[DEBUG] adjustPictureArray -awakeFromNib");
    NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:10];
    NSDictionary *pictDict = [DataModel picturesDict];
    for (NSString *key in [pictDict allKeys])
    {
        NSImage *image = [DataModel pictureDictWithID:[key intValue]];
NSMutableDictionary *imageDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                key, KEY_KEY,
                                image, IMAGE_KEY,
                                nil];
        [mArray addObject:imageDict];
    }

    [self setImagesArray:[NSArray arrayWithArray:mArray]];
}

        ---

When I run this code, I get:

2009-06-11 07:41:11.092 app[76813:10b] [DEBUG] adjustPictureArray - awakeFromNib 2009-06-11 07:41:11.188 app[76813:10b] [DEBUG] about to initWithWindowNibName:@PictureList 2009-06-11 07:41:11.214 app[76813:10b] [DEBUG] AFTER initWithWindowNibName:@PictureList
2009-06-11 07:41:11.244 app[76813:10b] An uncaught exception was raised
2009-06-11 07:41:11.244 app[76813:10b] [<PictureListController 0x141e10> valueForUndefinedKey:]: this class is not key value coding- compliant for the key IMAGE. 2009-06-11 07:41:11.244 app[76813:10b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<PictureListController 0x141e10> valueForUndefinedKey:]: this class is not key value coding-compliant for the key IMAGE.'
2009-06-11 07:41:11.245 app[76813:10b] Stack: (
   [etc., snip]

        ---

I can change things around to do them in a different order and get the error to come out for key 'KEY' instead of 'IMAGE', but it's basically the same problem. If I break on the code and examine my array (the referencedObject), it's an array of dictionaries, with keys KEY and IMAGE, as expected, long before the view displays.

Am I missing some best-practices thing, here? Is there a special ordering in which I need to do this stuff? I swear this worked a week ago and I didn't change anything (other than to install the new SDK <sigh>)

Thanks!

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to