• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird race condition affecting bindings.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird race condition affecting bindings.


  • Subject: Weird race condition affecting bindings.
  • From: Mac First <email@hidden>
  • Date: Thu, 11 Jun 2009 07:43:34 -0700

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Weird race condition affecting bindings.
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Get|SetControlProperty() equivalent
  • Next by Date: Growing UITextView in UITableView
  • Previous by thread: Re: Carbon Boolean
  • Next by thread: Re: Weird race condition affecting bindings.
  • Index(es):
    • Date
    • Thread