• 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: customize the nstextfield format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: customize the nstextfield format


  • Subject: Re: customize the nstextfield format
  • From: "Alan Smith" <email@hidden>
  • Date: Sat, 25 Aug 2007 13:13:18 -0400

Hello Jim,

NSControl has a setFormatter: method, you are supposed to pass in a
NSFormatter(sub)class. There are a couple formatters that Apple
supplies, NSDateFormatter and NSNumberFormatter, the latter might work
for you.

Once you have the string entered into the text field in the desired
format you can use the - [NSString componentsSeparatedByString:]
method. For example:

// Get formatted string
NSString *ipAddress = [ipAddressField stringValue];
// Split it into pieces
NSArray *ipSections = [ipAddress componentsSeparatedByString: @"."];
// Do what you want with the pieces

Hope that helps.

Peace, Alan

--
My blog: cocoalatte.info

// Things I've said -------------------------
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that personal beliefs are not something to
argue or fight over, it shall evolve."
_______________________________________________

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: 
 >customize the nstextfield format (From: Jim Raynor <email@hidden>)

  • Prev by Date: Re: How do you found your way around in the ref docs?
  • Next by Date: Re: How do you found your way around in the ref docs?
  • Previous by thread: customize the nstextfield format
  • Next by thread: how to create Non-Aqua Scrollbar in iApps
  • Index(es):
    • Date
    • Thread