Friday, January 22, 2010

Drupal for iPhone app Update - NSSCanner no more

I figured out that the Cocoa XMLRPC library was already doing the work of parsing out the XMLRPC responses. Basically after you get the XMLRPC response, create a NSDictionary and retrieve the key/value pair. Here's some sample code

//So you could put this in the - (void)viewDidLoad
NSString *drupalurl = @"";

//XMLRPC request
XMLRPCRequest *reqUserInfo = [[XMLRPCRequest alloc] initWithHost:[NSURL URLWithString:drupalurl]];
[reqUserInfo setMethod:@"system.connect" withObjects:[NSArray arrayWithObjects: nil]];
XMLRPCResponse *Response = [XMLRPCConnection sendSynchronousXMLRPCRequest:reqUserInfo];

//Whole XMLRPC response dumped into dictionary.
NSMutableDictionary *dict = [Response object];

//Anonymous sessid retrieved from the dictionary
NSString *anonsessid = [dict objectForKey:@"sessid"];


No comments: