• 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
Re: Cocoa Bindings, NSMatrix, setting programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Bindings, NSMatrix, setting programmatically


  • Subject: Re: Cocoa Bindings, NSMatrix, setting programmatically
  • From: Allan Odgaard <email@hidden>
  • Date: Thu, 29 Apr 2004 07:53:21 +0200

On 28. Apr 2004, at 20:43, Renaud Boisjoly wrote:

Oh, buy... communication... let me do this again, with source (see end of mail for a link) and more...

The archive seems to be broken, so I set out simply to create an example project, and it seems that your problem would actually be a bug in the NSMatrix class :(

What I did (to isolate the bug) was create a document based application, drag a text field into the MyDocument.nib window and alt-resized it so that it would turn into an NSMatrix of 7 fields, which I gave the names of the days in a week and made the type of the NSMatrix of List type.

I bound "selectedValues" (for which the documentation says: "An NSArray of NSStrings that specify the currently selected items in the NSMatrix.") to File's Owner with a key path of "selectedDays".

To MyDocument.m (which is File's Owner) I added:
- (NSArray*)selectedDays
{
NSLog(@"%s", _cmd);
return [NSArray arrayWithObjects:
@"Tuesday",
@"Friday",
nil];
}

- (void)setSelectedDays:(NSArray*)anArray
{
NSLog(@"%s %@", _cmd, [anArray description]);
}

Thus I was expecting the matrix to show up with Tuesday and Friday as selected days.

What happens is: when my application starts it *does* call selectedDays, but *nothing* is selected. And now for the strange part: if I click on any day other than Tuesday or Friday it calls setSelectedDays: with an array containing the name of the day. But when clicking Tuesday or Friday, it calls setSelectedDays: with an empty array, and it does *not* select that day in the GUI (but it does on a second click).

This latter part makes me almost certain that NSMatrix contains a bug related to initial selection of values.

I don't know if mmalc or Scott have anything to add? otherwise I'd file this as a bug and start looking at workarounds... :-/

[...]
Yes, I tried setWeekdays (my original line said setAllWeekdays, an error in the email but not the actual code, remnants from a test I did...), but perhaps doing it in the init method of the MCTask is wrong? When else can I do this...

Doing it in init is fine. Even though no-one will observe your event at that time. When an observer is added, it will read the current value from the observe-ee and make sure the other end of the binding gets that value.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Cocoa Bindings, NSMatrix, setting programmatically (From: Renaud Boisjoly <email@hidden>)
 >Re: Cocoa Bindings, NSMatrix, setting programmatically (From: Renaud Boisjoly <email@hidden>)
 >Re: Cocoa Bindings, NSMatrix, setting programmatically (From: Allan Odgaard <email@hidden>)
 >Re: Cocoa Bindings, NSMatrix, setting programmatically (From: Renaud Boisjoly <email@hidden>)

  • Prev by Date: Detect when menu closed
  • Next by Date: Re: Enable Objective-C exception handling. [-fobjc-exceptions] causes additional warnings on pointers?
  • Previous by thread: Re: Cocoa Bindings, NSMatrix, setting programmatically
  • Next by thread: Re: Cocoa Bindings, NSMatrix, setting programmatically
  • Index(es):
    • Date
    • Thread