Estoy tratando de verificar la URL ingresada por el usuario, pero estoy luchando contra algunos errores y advertencias.Comprobar la cadena que contiene la URL para "http: //"
-(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];
}
Ellos dicen:
NSString
puede no responder a-rangeWithString
sin usar variablesurlAddress
en la condición "if ... else" (para ambos)
urlAddress
no declarados: en elURLRequest
¿Alguien tiene alguna idea de qué hacer?