基本上我想设置
内容类型:应用程序/json;
为了调用 dot net web 服务并让它返回 json 到 iphone 应用程序。
目前我有
NSString * jsonres = [[NSString alloc] initWithContentsOfURL:url];
为了发出阻止请求,我需要什么?
基本上我想设置
内容类型:应用程序/json;
为了调用 dot net web 服务并让它返回 json 到 iphone 应用程序。
目前我有
NSString * jsonres = [[NSString alloc] initWithContentsOfURL:url];
为了发出阻止请求,我需要什么?
您需要使用 NSURLMutableRequest,在这里您可以为内容类型和排序添加标头,这里是参考,http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/ Reference/Reference.html#//apple_ref/occ/cl/NSMutableURLRequest,一旦你设置了你的请求,你就可以使用这个方法添加值 - (void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field 类似于
[request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];