1
NSString *urlString = [NSString stringWithFormat:@"http://shareaspetto.com/share/updateprofile.php?name=%@&gender=%@&email=%@&about_us=%@&id=%@&image=%@", nameString, genderString, emailString, aboutusString, idString, imgNameString];
NSLog(@"urlString = %@", urlString);
while ([urlString rangeOfString:@" "].location != NSNotFound) {
    urlString = [urlString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
}    
NSString *rplyString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];

上記のコードをコンパイルすると、警告Incompatible pointer types sending 'NSURL *__strong' to parameter of type 'NSString *'が発生します。

4

1 に答える 1

1

隠し文字列stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding

NSString *urlString = [NSString stringWithFormat:@"http://shareaspetto.com/share/updateprofile.php?name=%@&gender=%@&email=%@&about_us=%@&id=%@&image=%@", nameString, genderString, emailString, aboutusString, idString, imgNameString];
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
NSLog(@"urlString = %@", urlString);
while ([urlString rangeOfString:@" "].location != NSNotFound) {
    urlString = [urlString stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
}

NSString *rplyString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
于 2013-02-07T06:00:38.403 に答える