我想下面的NSString API調用轉換爲NSURL對象:iPhone轉換的NSString NSURL錯誤
http://beta.com/api/token=「69439028」
下面是我設置的對象。我躲過了引號用反斜槓:
NSString *[email protected]"http://beta.com/api/token=\"69439028\"";
NSLog(@"theTry=%@",theTry);
NSMutableURLRequest *url = [[NSURL alloc] URLWithString:theTry];
NSLog(@"url=%@",url);
每次我運行它,我不斷收到此錯誤:
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'
是否有人可以告訴我怎樣才能正確這個字符串轉換成一個NSURL?
或者,你可以得到一個自動釋放的對象與NSURL * URL = [NSURL URLWithString:theTry]。 – 2010-07-28 20:04:55
@Tom:我試過「NSURL * url = [NSURL URLWithString:theTry]」,它一直返回給我一個空對象。 – unicornherder 2010-07-28 20:16:03
@ Dutchie432&Dave:我也試過「NSURL * url = [[NSURL alloc] initWithString:theTry]」,它也給了我一個空對象 – unicornherder 2010-07-28 20:17:24