objective c - Afnetworking post array -


I'm trying to post as a post instead of a dictionary, though I get an error :

  sending an incompatible index type type NSMutableArray type parameter is NSDictionary  

here is the code

  FTPTRAQ Operation Manager * Manager = [FHTPRAACAST Operation Manager Manager]; NSMutableArray * parameter = @ [@ "afu", @ "bar"]; [Manager post: @ "http://example.com/resources.json" parameter parameter: criterion success: ^ (fttpequest operation * operation, id response object) {nslog (@ "jessonon:% @", reaction object); } Failure: ^ (FHTPPKAESTA Operation * Operation, NSERR * error) {NSLog (@ "error:% @", error); }];  

How can I post Array's contents only?

Update:

This code works, but I like the answer given below as handles its cleaner and AF serialization. I guess the body requesting But how can I see what the body is?

  NSError * error; NSDTA * JSNET Data = [NSJSONSArilization DatavijanOnBiz: Parameter Option: NSJSNDritingRelative Error: & amp; Error]; NSString * body = [[NSString alloc] initWithData: jsonData encoding: NSUTF8StringEncoding]; NSMutableURLRequest * Request = [NSMutableURL request request with url: [NSURL URLWithString: @ "http://example.com/resources.json"] Cash Policy: NSURLRequestReloadIgnoringCacheData Timeout Interval: 10]; [Set http system: @ "post"]; [Request Set Value: @ "App / Jason" HTTP Headerfield: @ "Content-Type"]; [SetHttpBD: [Body Dataupting Encoding: NSUFF 8 string encoding]]; AFHTTPRequestOperation * op = [[AFHTTPRequestOperation alloc] initWithRequest: request]; Op.responseSerializer = [AFJSONResponseSerializer serializer]; [Op setcompletionBlockWithSuccess: ^ (FHTPPKAESTA Operation * Operation, ID Reaction Object) {NSLog (@ "Jason Reaction Object:% @", ReactionObject); } Failure: ^ (FHTPPKAESTA Operation * Operation, NSERR * Error) {NSLog (@ "Error:% @", [Error localization]]; }]; [Op start];  

I assume that you want foo and Bar Are your parameters at no cost? If so, then you want to do something like this

  FHttpAkAST Operation Manager * Manager = [AFHTPPRCF Operation Manager Manager]; NSMutableArray * parameter = @ [@ "afu", @ "bar"]; NSDictionary * params = [[NSDictionary alloc] initWithObjects: @ [[NSNull null], [NSNull faucet] for: parameter]; [Manager post: @ "http://example.com/resources.json" Parameter: Parameters Success: ^ (FHttpKAEASTA Operation * Operation, ID Response Object) {NSLog (@ "Jasonn:% @", ReactionObject); } Failure: ^ (FHTPPKAESTA Operation * Operation, NSERR * error) {NSLog (@ "error:% @", error); }]; Try adding  

edit

  manager.requestSerializer = [AFJSONRequestSerializer serializer]; Manager.responseSerializer = [AFJSONResponseSerializer serializer];  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -