views:

35

answers:

1

I cant to set Meta and set Location in ObjectiveFlickr

if I do only one it works fine, but if I do both it only does the first one

- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary

{ NSLog(@"%s %@ %@", PRETTY_FUNCTION, inRequest.sessionInfo, inResponseDictionary);

if (inRequest.sessionInfo == kUploadImageStep) {
    snapPictureDescriptionLabel.text = @"Setting properties...";


    NSLog(@"%@", inResponseDictionary);
    NSString *photoID = [[inResponseDictionary valueForKeyPath:@"photoid"] textContent];

    flickrRequest.sessionInfo = kSetImagePropertiesStep;
    [flickrRequest callAPIMethodWithPOST:@"flickr.photos.setMeta" arguments:[NSDictionary dictionaryWithObjectsAndKeys:photoID, @"photo_id", @"Snap and Run", @"title", @"Uploaded from my iPhone/iPod Touch", @"description", nil]];        
    flickrRequest.sessionInfo = kSetImagePropertiesStep;
    [flickrRequest callAPIMethodWithPOST:@"flickr.photos.geo.setLocation" arguments:[NSDictionary dictionaryWithObjectsAndKeys:photoID, @"photo_id",@"34" ,@"lat",@"-118",@"lon", nil]];                        



}
else if (inRequest.sessionInfo == kSetImagePropertiesStep) {
    [self updateUserInterface:nil];     
    snapPictureDescriptionLabel.text = @"Done";

    [UIApplication sharedApplication].idleTimerDisabled = NO;       

}

}

A: 

You need to define a new step (for example: NSString *kSetImageGeoInfoStep = @"kSetImageGeoInfoStep") and set the sessionInfo to this new step by adding an additional condition in the if/else if block to accommodate the geo info update. The code should look something like this (disclaimer - not compiled so syntax error are possible:

if (inRequest.sessionInfo == kUploadImageStep) {
    snapPictureDescriptionLabel.text = @"Setting properties...";


    NSLog(@"%@", inResponseDictionary);
    NSString *photoID = [[inResponseDictionary valueForKeyPath:@"photoid"] textContent];
    [photoID retain];

    flickrRequest.sessionInfo = kSetImagePropertiesStep;
    [flickrRequest callAPIMethodWithPOST:@"flickr.photos.setMeta" arguments:[NSDictionary dictionaryWithObjectsAndKeys:photoID, @"photo_id", @"Snap and Run", @"title", @"Uploaded from my iPhone/iPod Touch", @"description", nil]];            

}
else if (inRequest.sessionInfo == KSetImagePropertiesStep) {
    snapPictureDescriptionLabel.text = @"Setting Geo info..."; 
    flickrRequest.sessionInfo = kSetImageGeoInfoStep;
    [flickrRequest callAPIMethodWithPOST:@"flickr.photos.geo.setLocation" arguments:[NSDictionary dictionaryWithObjectsAndKeys:photoID, @"photo_id",@"34" ,@"lat",@"-118",@"lon", nil]];                        
}
else if (inRequest.sessionInfo == kSetImageGeoInfoStep) {
    [self updateUserInterface:nil];     
    snapPictureDescriptionLabel.text = @"Done";
    [photoID release];
    photoID = nil;

    [UIApplication sharedApplication].idleTimerDisabled = NO;       

}
cameron