As something else to post on this blog, I thought I’d add some code help. Going through a number of questions on StackOverflow that’s reached a number of thousand views, I thought I’d post some of them up on here.

To set a text character limit in an NSTextField, the following code should be placed into your view controller and make sure NSTextField delegate is set to self.


-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//limit the size :
int limit = 20;
return !([textField.text length]>limit && [string length] > range.length);
}

 

2 Responses to Setting Max Characters in an NSTextField [Code Snippet]

  1. RAYMOND says:


    Pillspot.org. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription drugs. Buy pills online

    Buy:Zocor.Zetia.Nymphomax.Buspar.Benicar.Lipothin.Lipitor.Acomplia.SleepWell.Prozac.Amoxicillin.Lasix.Ventolin.Cozaar.Seroquel.Female Pink Viagra.Female Cialis.Aricept.Wellbutrin SR.Advair….

  2. MARIO says:


    Pillspot.org. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. Low price drugs. Order drugs online

    Buy:Lumigan.Actos.Valtrex.100% Pure Okinawan Coral Calcium.Zyban.Mega Hoodia.Nexium.Accutane.Zovirax.Petcam (Metacam) Oral Suspension.Prevacid.Arimidex.Prednisolone.Synthroid.Human Growth Hormone.Retin-A….

Leave a Reply