user464193
user464193

Reputation:

NSString Character found

I have on nsstring object in which sometimes phone number gets stored and sometimes email address, i just need to ask that how to find any character suppose @ in a string, when email address is typed.

Upvotes: 0

Views: 198

Answers (1)

Twelve47
Twelve47

Reputation: 3984

This is how you could check for @ as a substring

if ([string rangeOfString:@"@"].location == NSNotFound) {
  // Number
} else {
  // Email
}

Upvotes: 1

Related Questions