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 <andf...@gmail.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to