> Message: 8 > Date: Thu, 03 Mar 2011 18:29:23 -0800 (PST) > From: Jon Sigman <rf_...@yahoo.com> > Subject: Re: Setting a delegate on a UITextField > To: Cocoa Developers <cocoa-dev@lists.apple.com> > Message-ID: <977310.3842...@web31911.mail.mud.yahoo.com> > Content-Type: text/plain; charset=us-ascii > > Okay, part II: > > Is there a way to allow only a certain number of characters in a UITextField? > Should this be done in the -textFieldDidEndEditing delegate callback, with an > alert to the user, or just truncating the field, or ...? > > -Jon > > > > > > ------------------------------ > > Message: 9 > Date: Thu, 03 Mar 2011 18:51:39 -0800 (PST) > From: Dianne <pinkpoppy_sandia...@yahoo.com> > Subject: Re: Setting a delegate on a UITextField > To: Jon Sigman <rf_...@yahoo.com>, Cocoa Developers > <cocoa-dev@lists.apple.com> > Message-ID: <713875.69795...@web120609.mail.ne1.yahoo.com> > Content-Type: text/plain; charset=us-ascii > > there is, you need to use a formatter for that, you can even set the allowed > characters to be inputted to the textfield. > check NSFormatter if it is of any help, you can also extend the class to > adjust > to your needs.
Hmm, interesting, I didn't think of that. I remember in some earlier code I did something like so, using a notification... just as an example in some iOS app: - (void)textFieldTextDidChange:(NSNotification*)aNotification { NSInteger remaining = [[aNotification.object text] length]; if (remaining < self.minLength) { self.tableView.tableFooterView.hidden = NO; [self.headerLabel setText:[NSString stringWithFormat:NSLocalizedString(@"Remaining characters required: %d", nil), (self.minLength - remaining)]]; self.navigationItem.rightBarButtonItem.enabled = NO; } else { self.tableView.tableFooterView.hidden = YES; self.navigationItem.rightBarButtonItem.enabled = YES; } } Overkill?_______________________________________________ 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