如何在post请求Objective-C中发送JSON数据?

如何在post请求Objective-C中发送JSON数据?,objective-c,json,Objective C,Json,向服务器发送Json数据时出错。我使用以下代码将NSMutableDictionary更改为JSON NSString* jsonString1 = [postDict JSONRepresentation]; NSLog(@"%@",jsonString1); JSON格式: {"user_email":"gupta.nivrit@gmail.com","firstname":"nivrit","user_password":"1234","confirm_passwar

向服务器发送Json数据时出错。我使用以下代码将NSMutableDictionary更改为JSON

NSString* jsonString1 = [postDict JSONRepresentation];
NSLog(@"%@",jsonString1); 
JSON格式:

         {"user_email":"gupta.nivrit@gmail.com","firstname":"nivrit","user_password":"1234","confirm_passward":"1234"}
我使用以下方法将此JSON格式发送到服务器:

NSMutableDictionary *responseDict = 
    (NSMutableDictionary *)[[mWebServiceHelperOBJ 
              makeCallToURL:@"register.php" 
              withDataPost:jsonString1] JSONValue];
当我实现这段代码时,我收到了这个问题

incompatible pointer type sending  NSString to parameter of type  NSMutableDictionary.
如果你的方法

- (NSString *)makeCallToURL:(NSString*)url withDataPost:(NSMutableDictionary*)dict;
与此问题中的相同:,则请求数据的JSON编码在内部完成 这个方法,所以您应该直接用
postDict
调用它, 而不是JSON字符串
jsonString1

NSMutableDictionary *responseDict = 
    (NSMutableDictionary *)[[mWebServiceHelperOBJ makeCallToURL:@"register.php" 
                                                   withDataPost:postDict] JSONValue];

(假设
postDict
是一个
NSMutableDictionary

很高兴知道你为什么“不接受”我的答案。。。