ios - AFNetworking JSONRequestSerializer POST requestWithMethod Newb Example -


i'm trying json post request (to create new user) ios app cloud back-end rest api using afnetworking. in view controller, i'm doing,

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];  nsstring *urlstring = api_base_url; nsdictionary *parameters = @{@"username": self.usernametextfield.text,                              @"password": self.passwordtextfield.text};  manager.requestserializer = [[afjsonrequestserializer serializer] requestwithmethod:@"post" urlstring:urlstring parameters:parameters error:nil]; 

i've reviewed the docs, so post, , r.wenderlich tutorial, frankenstein-ing skills running out.

the compiler complains about

incompatible pointer types assigning 'afhttprequestserializer<afurlrequestserialization> *' 'nsmutableurlrequest *' 

has got pointer working example of or guidance on might wrong code.

specifically, how initiate action callback?

try this:

afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; nsdictionary *params = @{@"username": username, @"password": password}; manager.responseserializer = [afjsonresponseserializer serializer]; // if response json format [manager post:@"http://asd.com/login.php" parameters:params success:^(afhttprequestoperation *operation, id responseobject) {     nslog(@"%@", responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) {     nslog(@"%@", error); }]; 

treat responseobject nsdictionary.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -