refactor initialization of TURAnselGallery to take the parent controller as
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Nov 2008 01:40:40 +0000 (20:40 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Nov 2008 01:40:40 +0000 (20:40 -0500)
a parameter, thus saving us from having to remember to set it ourselves ;)

iPhoto2Ansel/TURAnsel.m
iPhoto2Ansel/TURAnselGallery.h
iPhoto2Ansel/TURAnselGallery.m

index 5075b0c..6ba7138 100644 (file)
 - (NSDictionary *)createNewGallery: (NSDictionary *)params
 {
     NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
-                                [params valueForKey:@"name"], @"name", nil];
+                                [params valueForKey: @"name"], @"name", nil];
     NSArray *apiparams = [NSArray arrayWithObjects:
                              @"ansel", attributes, nil]; 
-    XMLRPCResponse *response = [self callRPCMethod:@"images.createGallery"
-                                        withParams:apiparams];
+    XMLRPCResponse *response = [self callRPCMethod: @"images.createGallery"
+                                        withParams: apiparams];
     if (state != TURAnselStateError) {
         NSDictionary *results = [NSDictionary dictionaryWithObjectsAndKeys:
                                     response, @"share_id",
-                                    [params valueForKey:@"name"], @"attribute_name",
+                                    [params valueForKey: @"name"], @"attribute_name",
                                     @"", @"attribute_desc",
-                                    [NSNumber numberWithInt:0], @"attribute_images",
-                                    [NSNumber numberWithInt:0], @"attribute_default", nil];
-        TURAnselGallery *newGallery = [[TURAnselGallery alloc] initWithObject:results];
-        [newGallery setAnselController: self];
-        [galleryList addObject:newGallery];
+                                    [NSNumber numberWithInt: 0], @"attribute_images",
+                                    [NSNumber numberWithInt: 0], @"attribute_default", nil];
+        TURAnselGallery *newGallery = [[TURAnselGallery alloc] initWithObject: results
+                                                                   controller: self];
+        [galleryList addObject: newGallery];
         return results;
     }
     
@@ -247,7 +247,8 @@ objectValueForTableColumn:(NSTableColumn *)tc
     if (state != TURAnselStateError) {
         state = TURAnselStateConnected;
         for (NSString *gal in galleries) {
-            TURAnselGallery *theGallery = [[TURAnselGallery alloc] initWithObject:gal];
+            TURAnselGallery *theGallery = [[TURAnselGallery alloc] initWithObject: gal
+                                                                       controller: self];
             [theGallery setAnselController: self];
             [galleryList addObject: theGallery];
             [theGallery release];
index 6083240..ded3b14 100644 (file)
@@ -38,7 +38,7 @@ typedef enum {
 @property (readwrite) int galleryDefaultImage;
 @property (readonly, retain) NSURL *galleryDefaultImageURL;
 
-- (id)initWithObject:(id)galleryData;
+- (id)initWithObject:(id)galleryData controller:(TURAnsel *)controller;
 - (int)galleryId;
 - (void)requestDefaultImageURL;
 - (void)parseImageUrlRequest:(XMLRPCResponse *)response;
index 2e7c085..33fc030 100644 (file)
@@ -28,7 +28,7 @@
 /**
  * Init a gallery object
  */
-- (id)initWithObject: (id)galleryData
+- (id)initWithObject:(id)galleryData controller:(TURAnsel *)controller
 {
     [super init];
     [self setValue: [galleryData valueForKey:@"share_id"]
@@ -41,7 +41,7 @@
             forKey:@"galleryImageCount"];    
     [self setValue: [galleryData valueForKey:@"attribute_default"]
             forKey:@"galleryDefaultImage"];
-
+    [self setAnselController: controller];
     return self;
 }