Define a minimum number character in UITextfield

79 views Asked by At

I wish verify a number letter in UITextfield, and also if my textfield is empty. But, I have a problem between NSUInteger and int. Thanks for your answers.

- (void)saveProfile {

    NSUInteger *minID = [_userID.text length];

    if ([_userID.text isEqualToString:@""] == NO || minID >= 4) {
         // Succes
    } else { // Error }
}
1

There are 1 answers

0
Midhun MP On BEST ANSWER

Change this code:

NSUInteger *minID = [_userID.text length];

to

NSUInteger minID = [_userID.text length];

The length property is defined like:

@property(readonly) NSUInteger length 

So the length getter method will return a NSUInteger not NSUInteger *

Refer : NSString class reference for more details