Working on an app that validates a URL before accepting the submission.
The follow code accepts simple urls such as www.google.com, but does not worth with more complex urls such as www.google.com/?test-test
- (BOOL) validateUrl: (NSString *) candidate {
NSString *urlRegEx =
@"((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
return [urlTest evaluateWithObject:candidate];
}