uni*_*der 7 iphone objective-c
我正在尝试将以下NSString api调用转换为NSURL对象:
http://beta.com/api/token="69439028 "
这是我设置的对象.我用反斜杠转义引号:
NSString *theTry=@"http://beta.com/api/token=\"69439028\"";
NSLog(@"theTry=%@",theTry);
NSMutableURLRequest *url = [[NSURL alloc] URLWithString:theTry];
NSLog(@"url=%@",url);
Run Code Online (Sandbox Code Playgroud)
每次我运行这个,我都会收到这个错误:
2010-07-28 12:46:09.668 RF[10980:207] -[NSURL URLWithString:]: unrecognized selector sent to instance 0x5c53fc0
2010-07-28 12:46:09.737 RF[10980:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL URLWithString:]: unrecognized selector sent to instance 0x5c53fc0'
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何正确地将此字符串转换为NSURL?
Dut*_*432 32
您正在声明NSMutableURLRequest类型的变量并使用NSURL初始化函数(排序).
NSMutableURLRequest *url = [[NSURL alloc] URLWithString:theTry];
Run Code Online (Sandbox Code Playgroud)
尝试
NSURL *url = [[NSURL alloc] initWithString:theTry];
Run Code Online (Sandbox Code Playgroud)
请注意,自从我做了任何iPhone开发以来已经有一段时间了,但我认为这看起来非常准确.
| 归档时间: |
|
| 查看次数: |
34062 次 |
| 最近记录: |