- (GTLServiceGmail *)gmailService
{
if (!_gmailService) {
_gmailService = [GTLServiceGmail new];
// Have the service object set tickets to fetch consecutive pages
// of the feed so we do not need to manually fetch them.
// This will disable our manual fetching and the view will be only updated after all result is loaded.
_gmailService.shouldFetchNextPages = YES;
// Have the service object set tickets to retry temporary error conditions
// automatically.
_gmailService.retryEnabled = YES;
_gmailService.authorizer = [self.account googleAuth];
}
return _gmailService;
}
- (void)listMessagesMaxResults:(NSUInteger)maxResults completion:(void (^)(NSArray *messageIds))completion
{
GTLQueryGmail *query = [GTLQueryGmail queryForUsersMessagesList];
query.userId = self.account.email;
query.maxResults = maxResults;
[self.gmailService executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLGmailListMessagesResponse *object, NSError *error) {
}];
}
2014-06-27 10:53:40.398 Stitch[57164:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTLGmailListMessagesResponse items]: unrecognized selector sent to instance 0xf3c6200'
*** First throw call stack:
(
0 CoreFoundation 0x052855e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x04ec78b6 objc_exception_throw + 44
2 CoreFoundation 0x05322903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0527590b ___forwarding___ + 1019
4 CoreFoundation 0x052754ee _CF_forwarding_prep_0 + 14
5 Stitch 0x00275c63 -[GTLService mergedNewResultObject:oldResultObject:forQuery:] + 2563
6 Stitch 0x002726c3 -[GTLService handleParsedObjectForFetcher:] + 771
7 libobjc.A.dylib 0x04ed981f -[NSObject performSelector:withObject:] + 70
8 Foundation 0x0490f9d8 __NSThreadPerformPerform + 285
9 CoreFoundation 0x0520e83f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
10 CoreFoundation 0x0520e1cb __CFRunLoopDoSources0 + 235
11 CoreFoundation 0x0522b29e __CFRunLoopRun + 910
12 CoreFoundation 0x0522aac3 CFRunLoopRunSpecific + 467
13 CoreFoundation 0x0522a8db CFRunLoopRunInMode + 123
14 GraphicsServices 0x067189e2 GSEventRunModal + 192
15 GraphicsServices 0x06718809 GSEventRun + 104
16 UIKit 0x026bbd3b UIApplicationMain + 1225
17 Stitch 0x00015f08 main + 216
18 libdyld.dylib 0x05a19701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
let newQuery: GTLQueryGmail = GTLQueryGmail.queryForUsersMessagesList() as GTLQueryGmail
newQuery.maxResults = 30
self.gmailService.executeQuery(newQuery, delegate: self, didFinishSelector: Selector("completionHandler:messageRespone:error:"))