From dd5973a0abb4da7e9806537e5b221deb5528ff70 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 21 Dec 2010 13:54:59 -0500 Subject: [PATCH] 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 ... --- ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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]; -- 2.11.0