Im trying to limit the the character length in a text field but i keep having problem with my code
AppDelegate.h
AppDelegate.m
what am i doing wrong i'm getting an error on
Property 'text' not found on an object of type 'NSTextField *'
AppDelegate.h
Code:
- (BOOL)textField:(NSTextField *)textField;
Code:
#define MAX_LENGTH 20
- (BOOL)textField:(NSTextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField.text.length >= MAX_LENGTH && range.length == 0)
{
return NO;
}
else
{return YES;}
}
Code:
if (textField.text.length >= MAX_LENGTH && range.length == 0)
Last edited by a moderator: