Be able to accept either a struct or array structure passed back from xmlrpc.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 21 Dec 2010 18:54:59 +0000 (13:54 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 21 Dec 2010 18:54:59 +0000 (13:54 -0500)
the datatype returned by xmlrpc seems to depend on the lunar cycle or sunspots, or ...

ApertureToAnselExportPlugin/TURAnselKit/TURAnsel.m

index 506cfac..a6fb060 100644 (file)
                                      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];