From: Michael J. Rubinsky Date: Tue, 21 Dec 2010 18:54:59 +0000 (-0500) Subject: Be able to accept either a struct or array structure passed back from xmlrpc. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dd5973a0abb4da7e9806537e5b221deb5528ff70;p=horde.git Be able to accept either a struct or array structure passed back from xmlrpc. the datatype returned by xmlrpc seems to depend on the lunar cycle or sunspots, or ... --- diff --git a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m index 506cfacb5..a6fb06008 100644 --- a/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m +++ b/ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m @@ -329,8 +329,20 @@ withParams: params withOrder: order]; if (results) { - NSDictionary *galleries = [results objectForKey: (id)kWSMethodInvocationResult]; - for (NSString *gal in galleries) { + NSObject *galleries = [results objectForKey: (id)kWSMethodInvocationResult]; + NSObject *g; + + // php's xmlrpc can return either a struct (NSDictionary) or an array, + // depending on it's mood, or the lunar cycle, or sunspots or... + // Compile warnings here are normal, since we don't know ahead of time + // if we will have a NSArray or NSDictionary + if (![galleries respondsToSelector:@selector(allValues)]) { + // php xmlrpc returned an array + g = galleries; + } else { + g = [galleries allValues]; + } + for (NSObject *gal in g) { TURAnselGallery *theGallery = [[TURAnselGallery alloc] initWithObject: gal controller: self]; [theGallery setAnselController: self];