I\'m trying to check if a given URL is valid and i\'m doing it like this:
- (BOOL)urlIsValid:(NSString *)address {
NSURL *testURL = [NSURL URLWithString:
check this method works fine for me
- (BOOL) validateUrl: (NSString *) candidate {
NSString *urlRegEx =
@"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
return [urlTest evaluateWithObject:candidate];
}
if (![self validateUrl:strRSSurl]) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Invalid url" message:[NSString stringWithFormat:@"\"%@\"",strRSSurl] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show ];
[alert setTag:7];
}
else
{
valid url
}