From cdbbd9e7334c7a775613b1d96b7714ddb62604de Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 25 Nov 2008 20:40:40 -0500 Subject: [PATCH] refactor initialization of TURAnselGallery to take the parent controller as a parameter, thus saving us from having to remember to set it ourselves ;) --- iPhoto2Ansel/TURAnsel.m | 21 +++++++++++---------- iPhoto2Ansel/TURAnselGallery.h | 2 +- iPhoto2Ansel/TURAnselGallery.m | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/iPhoto2Ansel/TURAnsel.m b/iPhoto2Ansel/TURAnsel.m index 5075b0c55..6ba7138f1 100644 --- a/iPhoto2Ansel/TURAnsel.m +++ b/iPhoto2Ansel/TURAnsel.m @@ -83,21 +83,21 @@ - (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]; diff --git a/iPhoto2Ansel/TURAnselGallery.h b/iPhoto2Ansel/TURAnselGallery.h index 608324077..ded3b1481 100644 --- a/iPhoto2Ansel/TURAnselGallery.h +++ b/iPhoto2Ansel/TURAnselGallery.h @@ -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; diff --git a/iPhoto2Ansel/TURAnselGallery.m b/iPhoto2Ansel/TURAnselGallery.m index 2e7c0858b..33fc03076 100644 --- a/iPhoto2Ansel/TURAnselGallery.m +++ b/iPhoto2Ansel/TURAnselGallery.m @@ -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; } -- 2.11.0