Method used:
-(NSString*) formatPhoneNumber:(NSString*) simpleNumber deleteLastChar:(BOOL)deleteLastChar
Returns an NSString object. In your case, you are calling the method correctly, but you are not setting the Returned NSString object to anything. He just hangs there. You must set the PhoneTextField to formatted text as follows:
phoneFieldTextField.text = [self formatPhoneNumber:phoneFieldTextField.text deleteLastChar:YES];
NOTE. If you want to know more about return methods, read the following:
If you notice that most methods are of type void . You know this when you see a method like this:
- (void)someMethod { int x = 10; }
Which means emptiness, that someMethod returns nothing to you. It just executes the code inside the method. Now, methods than returning an object or some other data type look like this:
- (int)returnSomething { int x = 10; return x; }
The first thing you notice is the return type, which is no longer invalid, is int. This means that the method will return an integer type. In this case, the code is executed, and you return the value of x.
This is only the beginning of the topic of return methods, but hopefully this will make it a little easier for you.
source share