• 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
Stumped by a custom NSView bindings behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stumped by a custom NSView bindings behavior


  • Subject: Stumped by a custom NSView bindings behavior
  • From: Steve Cronin <email@hidden>
  • Date: Fri, 31 Aug 2007 02:11:15 -0500

Folks;

This is the most complex Cocoa issue I've ever had to ask about!
I hope I can get the question stated well enough for a cogent response...


I have a custom NSView, MyCoolView, that allows me to create a configurable display of an array of images.
NOTE: I have MyCoolView working perfectly when I have only a single instance of it in my nib.
The problem is when I put a second instance of MyCoolView into the nib they both ALWAYS display the same array of images.
I use -exposeBinding in +initalize to facilitate interaction with MyCoolView.
+ (void)initialize
{
...
[self exposeBinding:@"imagesArray"];
...
}
MyCoolView also has the appropriate -imagesArray and -setImagesArray.
[NOTE: setImagesArray is never called directly by me!]


Over in my AppDelegate I have 2 outlets (coolView1 and coolView2) which are connected to the 2 instances of MyCoolView which are in the nib.
At various time I want to be able to display different arrays of images in each of these.
- (void)awakeFromNib
{
...
[coolView1 bind:@"imagesArray" toObject:self withKeyPath:@"imgArray1" options:nil];
[coolView2 bind:@"imagesArray" toObject:self withKeyPath:@"imgArray2" options:nil];
...
}
The AppDelegate also has the requisite setters and getters for imgArray1 and imgArray2 and I always use them.
And therein is the issue!!!


When I perform a [[NSApp delegate] setImgArray1:xyz] this spawns the expected call to the correct instance of MyCoolView -setImagesArray: and all is well with coolView1.

BUT if I immediately do NSLog(@"CoolView2's imageArray = %@", [coolView2 imagesArray]) it has the values xyz!
And sure enough if I display coolView2 it displays the images in xyz.
I never see a call made to coolView2's instance of MyCoolView - setImagesArray!


Conversely if I perform [[NSApp delegate setImgArray2:abc] the expected call to [CoolView setImagesArray:] is made but now [coolView1 imagesArray] is abc.

I've spent the better part of 2 days trying to pin this down and I'm just stumped.
I'm to the point where my brain wants me to just dupe the class and create a MyCoolView2 class but my gut won't let me...
Anyone have any ideas or seen this before?


Thank-you for reading this far and ANY thoughts you might share!
Steve
_______________________________________________

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


  • Prev by Date: Re: The magic of Key Value Coding and Key Value Observing
  • Next by Date: Re: Validating NSXMLDocument with DTD that has ANY condition
  • Previous by thread: Re: ObjC BOOL and boolean c expressions
  • Next by thread: Expand item in NSOutlineView
  • Index(es):
    • Date
    • Thread