Here's my attempt at inserting entry data to a table. According to
the protocol, it's supported. I obtained the recordFeed, and created
an object like it expects (I think), but my callback reports the error
above.
-(void)updateTableWithNewRecord {
GDataEntrySpreadsheetRecord *newRecord = [GDataEntrySpreadsheetRecord
recordEntry];
GDataSpreadsheetField *yearField = [GDataSpreadsheetField
fieldWithName:@"Year" value:@"2009"];
GDataSpreadsheetField *monthField = [GDataSpreadsheetField
fieldWithName:@"Month" value:@"December"];
GDataSpreadsheetField *weekField = [GDataSpreadsheetField
fieldWithName:@"Week" value:@"1"];
GDataSpreadsheetField *dateField = [GDataSpreadsheetField
fieldWithName:@"Date" value:@"12-1-2009"]
GDataSpreadsheetField *scoreField = [GDataSpreadsheetField
fieldWithName:@"Score" value:@"5000"];
NSArray *fields = [NSArray
arrayWithObjects:yearField,monthField,weekField,dateField,scoreField,nil];
[newRecord setFields:fields];
[newRecord setTitleWithString:@"Game1"]; //not sure if this is
correct
GDataServiceTicket *ticket;
NSURL *feedURL = [[[tableFeed entries]objectAtIndex:0]recordFeedURL];
ticket = [spreadsheetService fetchEntryByInsertingEntry:newRecord
forFeedURL:feedURL delegate:self didFinishSelector:@selector
(updateTicket:finishedWithEntry:error:)];
}
-(void)updateTicket:(GDataServiceTicket *)ticket finishedWithEntry:
(GDataEntrySpreadsheetRecord *)entry error:(NSError *)error {
if (error) {
NSLog(@"There has been an error updating the spreadsheet. %@",[error
description]);
}else {
NSLog(@"All appears ok, no errors updating spreadsheet.");
}
}
Does this make sense? Pay particular attention to [newRecord
setTitleWithString:], as I'm not sure if that's the correct usage.
Can you shed any light on the Error code?
Can you also explain what
[GDataSpreadsheetData spreadsheetDataWithStartIndex:? is for?
I've changed that value in the table example and nothing happens that
I can tell. Changing the setSpreadsheetHeaderWithRow moves the entry
up or down, and numberOfRows determines how many times the entry in
the table repeats. One problem I'm having is that
spreadSheetDataWithStartIndex: can't be the same as the
setSpreadsheetHeaderWithRow:. It spits out the error 403, "Invalid
row position for first record in table."
I'm not sure what I did, but I think it has something to do with me
changing my table to startIndex:0. Now, all of my requests add a new
line beneath the previous entry. I have 100 rows in this sheet, it
will be interesting to see what happens when I get to the end. The
table is set to overwrite, which is supposed to create a new row if it
hits the end.
Why numberOfRows:0 doesn't freak the thing out, I don't know, but
without it being 0, every entry is offset by one row down, where 1 = 1
blank row beneath header, 2 = 2 blank rows beneath header, etc.
Now that I'm this far, I can start incorporating this. Now that i
have the groundwork, I have to now work through Apple's rule that my
device should be sure there is an internet connection before
attempting anything. There's a new framework someone open sourced
called iPhone Dev Sugar that I will probably check into.
That and handling any Google Feed Errors are going to be the next
problem.