• 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: NSSegmentedControl send action only from the selected segment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSegmentedControl send action only from the selected segment


  • Subject: Re: NSSegmentedControl send action only from the selected segment
  • From: Keary Suska <email@hidden>
  • Date: Tue, 24 Mar 2009 09:04:17 -0600


On Mar 24, 2009, at 3:54 AM, Michele Barboni wrote:


On Mar 19, 2009, at 10:11 AM, Michele Barboni wrote:

Hi,

I've a NSSegmentedControl, 7 segments (labeled with weekdays), which has selectedIndex bound through a value transformer (NO reverse transformation) to NSDates.
Now, one of my awakeFromNib do this:


[sedutaDays setTarget:self];
[sedutaDays setAction:@selector(setWeekDay:)];
[sedutaDays setContinuous:YES];

setWeekDay: essentially change the day of the NSDate which NSSegmentedControl is bound to, by accessing the NSArrayController, selectedObjects:, objectAtIndex:0, and so on..

The problem is that my setWeekDay: action is sent only if I click the selected segment (set by binding), clicking on any of other 6 segments results in an attempt to reverse transform the value, which obviously fail with "[NSCFNumber timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x1019a40" since my value transformer doesn't reverse..

Any idea why it seems that only selected segments has setAction: ?


Passed two last days trying to understand why my NSSegmentedControl has this behavior but nothing came out.. I'm very disappointed..

It is not the behavior of the NSSegmentedControl, but bindings that you are not understanding. The binding is not trying to reverse transform , or you would get a different error message--assuming that your transformer is properly implemented, that is.


Refer to:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html#/ /apple_ref/doc/uid/TP40002149-186285


If your transformer does not support reverse transformations, then your setter method must assume that it is receiving a transformed value--in this case, an NSNumber. Does it make this assumption?

Note that the segment control would have sent your action method if you didn't get the exception first. Selecting the currently selected segment works because you are not changing the bound value, which is precipitating the exception.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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


References: 
 >NSSegmentedControl send action only from the selected segment (From: Michele Barboni <email@hidden>)
 >Re: NSSegmentedControl send action only from the selected segment (From: Michele Barboni <email@hidden>)

  • Prev by Date: Re: Class gets EXC_BAD_ACCESS only as NSOperation
  • Next by Date: Re: Simulating (or obtaining) menubar effect in a Cell
  • Previous by thread: Re: NSSegmentedControl send action only from the selected segment
  • Next by thread: problems with CAAnimation
  • Index(es):
    • Date
    • Thread