検索バーのユーザー検索テキストをjsonサービスに送信したいと思います。ここで問題はNSDataオブジェクトのnull値を返すことです。問題は何ですか?コンソールで印刷するのと同じURLを定義しても問題はないのですが?NSDataの実際の問題は何ですか
-(void)doIt{
NSURL *url = [NSURL URLWithString:weburls];
NSData *data =[NSData dataWithContentsOfURL:url];
[self getData:data];
}
私はそのように書きます場合、それは動作しますが、私は検索バーのイベントにサービスを呼び出したいけど
NSString *weburl = [NSString stringWithFormat:@"%@%@",
@"http://192.168.1.196/ravi/iphonephp?mname=",searchText];
NSLog(@"%@",weburl);
NSURL *url = [NSURL URLWithString:weburl];
NSLog(@"the url is : %@",url);
NSError *error;
NSData *data =[NSData dataWithContentsOfURL:url options:nil error:&error];
NSLog(@"Data is :%@",data);
NSLog(@"the Error massage is : %@",error);
[self getData:data];
は私に
customCellDemo[1553:f803] the url is : http://192.168.1.196/ravi/iphonephp?mname=a
2012-03-16 15:26:36.259 customCellDemo[1553:f803] Data is :(null)
2012-03-16 15:26:43.624 customCellDemo[1553:f803] the Error massage is : Error
Domain=NSCocoaErrorDomain Code=256 "The operation couldn’t be completed. (Cocoa error 256.)"
UserInfo=0x6ab2760 {NSURL=http://192.168.1.196/ravi/iphonephp?mname=a}
のようなコンソール値を与える問題があります
'+(id)dataWithContentsOfURL:(NSURL *)aURLオプション:(NSDataReadingOptions)マスクエラー:(NSError **)errorPtr' [(documentation)](https://developer.apple.com/library/mac) /documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/Reference/Reference.html#//apple_ref/doc/uid/20000172-BCIIDGEC)、エラーを確認してください –