I am trying to add a batch of cells to a Google Spreadsheet using the GData Objective-C Client as described here: http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction#Batch_requests.
Here is the code of interest:
GDataFeedSpreadsheetCell *batchFeed = [GDataFeedSpreadsheetCell spreadsheetCellFeed];
NSURL *batchUrl = [[batchFeed batchLink] URL];
NSMutableArray *cells = [NSMutableArray array];
GDataSpreadsheetCell *cell = [GDataSpreadsheetCell cellWithRow:1 column:1 inputString:@"test" numericValue:nil resultString:nil];
GDataEntrySpreadsheetCell *cellEntry = [GDataEntrySpreadsheetCell spreadsheetCellEntryWithCell:cell];
[cells addObject:cellEntry];
[batchFeed setEntries:cells];
GDataBatchOperation *op;
op = [GDataBatchOperation batchOperationWithType:kGDataBatchOperationInsert];
[batchFeed setBatchOperation:op];
[service fetchFeedWithBatchFeed:batchFeed forBatchFeedURL:batchUrl completionHandler:nil];
It doesn’t work. Clearly, the fetchFeedWithBatchFeed has no reference to my GDataWorksheetEntry object — so it doesn’t surprise me that it isn’t working.
What am I leaving out?
Thanks in advance.
And here is the final answer.
You must perform a query before the batch update to get the entries you are going to update. Sounds obvious in retrospect. Sure does make for a lot of nested blocks though.