I have no problems to get the value of name
in terms
(name of my blog post category) out of the xmlrpc server response object …
Server response:
responseArray: (
{ guid = "http://www.domain.com/wp/?p=12";
"post_id" = "123";
terms = (
{ name = "Uncategorized"; }
);
}
)
… with the following lines of Objective-C code:
NSMutableArray *responseArray = [[NSMutableArray alloc] init];
responseArray = [nodeSaveResponse object];
for(i = 0; i < responseArray.count; i++) {
NSString *postLink = [[responseArray objectAtIndex: i] valueForKey: @"guid"];
NSString *postId = [[responseArray objectAtIndex: i] valueForKey: @"post_id"];
NSMutableArray *catArray = [[NSMutableArray alloc] init];
catArray = [[responseArray objectAtIndex: i] valueForKey: @"terms"]];
NSArray *cat = [catArray valueForKey: @"name"];
NSString *myCatString = [cat objectAtIndex: 0];
}
But to send a new blog post fails because the following code to pack the category string is somehow wrong:
NSString *myCatString = @"MyCategory";
NSMutableDictionary *name = [[NSMutableDictionary dictionaryWithObjectsAndKeys: myCatString, @"name", nil];
NSMutableArray *catArray = [[NSMutableArray arrayWithObject: name];
NSMutableDictionary *values = [[NSMutableDictionary alloc] init];
[values setObject: title forKey: @"post_title"];
// and so on with other values - until here everything works well
[values setObject: catArray forKey: @"terms"]; // if this line is called, the request fails
NSArray *params = [NSArray arrayWithObjects: @"1", user, pass, values, nil];
[myRequest setMethod: @"wp.newPost" withParameter: params];
Any idea, where my fault is?
Cheers, Martin