Re: Working with a date and NSSteppers
Re: Working with a date and NSSteppers
- Subject: Re: Working with a date and NSSteppers
- From: Isaac Sherman <email@hidden>
- Date: Wed, 25 Dec 2002 23:59:50 -0500
on 12/25/02 11:22 PM, the method -(id)email@hidden:(id)
sender:@"Derek Arndt"; returned:
>
I'm writing an app where I've got a stepper connected up to an
>
NSTextField. The steppers value is shown in the text field (via
>
takeIntValue or something along those lines). This text field displays
>
a month (Jan-Dec) that should be able to be changed using the stepper.
>
The difficulty I'm having is figuring out how I can get this to work,
>
steppers work great with just integers, but using formatters doesn't
>
seem to get me where I'm going.
There are a couple of things you can do here. I would recommend using
takeObjectValue or takeStringValue; working with dates seems to mess with
NSStepper's ability to take ints. Attach a formatter to Both the stepper
and the text field. Does it display the month as January, or 1? If it's
numeric, you're that much closer. Use takeStringValueFrom: (from the
stepper to the text field and vice versa) and you should be set. If it's
textual, I'm not certain. Your formatter should still handle it; I'm just
not sure on whether the taking the string will convert properly in that
case. As long as it's being passed through a formatter, it should be read
correctly. Can't say for certain, but that's my $0.02.
On the other hand, you can make your own stepper subclass. I called mine a
SmartStepper, with an array of objects it would step through, passing the
value to it's "Field" outlet, and grabbing the new values whenever validate
was called. This worked well in theory, but it was a bit too much hassle
for what I planned on using it for.
Try takeString. It'll probably save you days of work.
HTH,
--
Isaac Sherman
MotaSoft Software
http://homepage.mac.com/huperzoevs/
_______________________________________________
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.