objective-cxcodeoauth-2.0google-toolbox-for-mac

GTM-OAuth 2.0 multiple post data parameters?


Simple one here. In GTM-OAuth 2.0 how do I send multiple post parameters? Here is how I post data now:

        NSString *postString = [NSString stringWithFormat:@"i=%@",articleIndex];
        [myFetcher setPostData:[postString dataUsingEncoding:NSUTF8StringEncoding]];

My question is how to send multiple parameters like i=1&t=2? is it like this?

Thank you!


Solution

  • It's just a different format string, like

    NSString *postString = [NSString stringWithFormat:@"i=%d&t=%d", i, t];
    

    Another common technique is to put parameters pairs as strings like @"i=1" into an NSArray, and use NSArray's joining method, [array componentsJoinedByString:@"&"], to make the full string.