我使用了 UserName=raj 和 pwd=space,但是 NSURL 中没有使用该 url 字符串。
NSString *urlstr = [NSString stringWithFormat:@"http://www.test.com/data/image/sd.php?Uname=raj&password=Space"];
NSURL *Url = [NSURL URLWithString:urlstr];
我使用了 UserName=raj 和 pwd=space,但是 NSURL 中没有使用该 url 字符串。
NSString *urlstr = [NSString stringWithFormat:@"http://www.test.com/data/image/sd.php?Uname=raj&password=Space"];
NSURL *Url = [NSURL URLWithString:urlstr];
如果您从文本字段中获取值,请尝试以下操作:
NSString *urlstr = [NSString stringWithFormat:@"http://www.test.com/data/image/sd.php?Uname=%@&password=%@",[usernameField.text stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding],[passwordField.text stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
尝试这个 :-
NSString *urlstr = [NSString stringWithFormat:@"http://www.test.com/data/image/sd.php?Uname=raj&password=Space"];
NSURL *url = [[NSURL alloc] initWithString:
[urlstr stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSURL *url = [NSURL URLWithString:@"http://www.test.com/data/image/sd.php?Uname=raj&password=Space"];