I am trying to check the URL entered by the user, but I am fighting against some errors and warnings.
-(BOOL) textFieldShouldReturn:(UITextField *)textField {
//check "http://"
NSString *check = textField.text;
NSString *searchString = @"http://";
NSRange resultRange = [check rangeWithString:searchString];
BOOL result = resultRange.location != NSNotFound;
if (result) {
NSURL *urlAddress = [NSURL URLWithString: textField.text];
} else {
NSString *good = [NSString stringWithFormat:@"http://%@", [textField text]];
NSURL *urlAddress = [NSURL URLWithString: good];
}
// open url
NSURLRequest *requestObject = [NSURLRequest requestWithURL:urlAddress];
}
They say:
NSStringmay not respond to-rangeWithString
Unused variableurlAddressin the condition "if … else" (for both)
urlAddressundeclared : in theURLRequest
Does anyone have any idea what to do?