Re: Newbie question
Re: Newbie question
- Subject: Re: Newbie question
- From: Nathan Day <email@hidden>
- Date: Tue, 9 Jul 2002 13:23:05 +0930
On Tuesday, July 9, 2002, at 07:52 AM, Andrew Merenbach wrote:
1. I had to copy and paste the controller into my nib file, since I
couldn't find a way to add one manually. How can I do this in the
future (in a non-document-based Cocoa app) without copying and pasting
from an existing nib?
You have to create a subclass of one of the cocoa classes (usually
NSWindowController) and then instantiate it. Look in the on line help
for details.
2. I need to take a string from a text field, convert it into a
numerical value, perform some operations on it, and then put the result
in a second text field. How can I do this, along with some
error-checking to make sure the user input only numbers, assuming I
don't use a formatter in my nib file?
Try the methods in NSControl, there are methods to get the value as an
string as well as int, double, float (though these last three might not
work because you text field contains a string). NSString also has
methods for converting a string into an int or float. You can create an
NSString from an int with something like [NSString
stringWithFormat:@"%i", theInt], it works the same as c's printf with
the addition of %@ to call and objects description method and print the
string. You can limit what a user can enter into a NSTextField by uses
of the number formater, in interface builder its the text field with the
number in it and the dollar sign above it just drag it to your text
field and then use the info panel to change the formate settings.
_______________________________________________
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.