• 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: Newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
References: 
 >Re: Newbie question (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: Re: Preview in Internet Explorer
  • Next by Date: Re: Preview in Internet Explorer
  • Previous by thread: Re: Newbie question
  • Next by thread: Drag and Drop file paths onto text field
  • Index(es):
    • Date
    • Thread