• 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: UITextField formatting for IP Address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UITextField formatting for IP Address


  • Subject: Re: UITextField formatting for IP Address
  • From: Alex Kac <email@hidden>
  • Date: Sat, 17 Oct 2009 12:23:02 -0500

Exactly. I know. I am still working on that, but I don't want to invest too much time in any one method until i know it can solve the issue. But that's my point. I can seem to find any really good way to do this in UITextField. So i am playing around with different methods and posted the closest working idea. On desktop it's easy.

So I am trying a variety of things and hoping someone has a better idea.

-- CEO WebIS
Sent from my phone

On Oct 16, 2009, at 11:46 PM, Andrew Farmer <email@hidden> wrote:

On 16 Oct 2009, at 17:54, Alex Kac wrote:
Here is my code, btw. It works OK, but it still has the issue of moving the cursor to the end. Perhaps there is no way to do this on the iPhone - I just don't want to bang my head for hours.

- (void)formatForIP:(UITextField*)textField string:(NSString*)string
{
long long ip = [[string stringByReplacingOccurrencesOfString:@"." withString:@""] longLongValue];


NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterNoStyle];
[numberFormatter setPositiveFormat:@"###,###,###,###"];
[numberFormatter setGroupingSize:3];
[numberFormatter setSecondaryGroupingSize:3];
[numberFormatter setGroupingSeparator:@"."];
[numberFormatter setUsesGroupingSeparator:YES];


textField.text = [numberFormatter stringFromNumber:[NSNumber numberWithLongLong:ip]];
[numberFormatter release];
}

This isn't a valid approach to formatting IP addresses - it considers "12.34.56.78" to be equal to "12.345.678", which isn't even a valid address, let alone equivalent.
_______________________________________________

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: 
 >UITextField formatting for IP Address (From: Alex Kac <email@hidden>)
 >Re: UITextField formatting for IP Address (From: Alex Kac <email@hidden>)
 >Re: UITextField formatting for IP Address (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: GC and atomic getters/setters
  • Next by Date: Re: Subclassing a view class from an external framework
  • Previous by thread: Re: UITextField formatting for IP Address
  • Next by thread: Any way to see all AppleEvents being sent in system?
  • Index(es):
    • Date
    • Thread