在我的 iPhone 应用程序中,我正在使用 ShareKit 实现 twitter 分享功能。当我尝试在设备中通过 twitter 分享时,应用程序崩溃了
- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection
我收到了错误消息;
NSInvalidArgumentException, [NSCFType tokenRequestTicket:didFinishWithData]:
但它在模拟器上运行良好。而且我之前在另一个应用程序中使用了相同的代码,没有任何更改,它仍然运行良好。问题仅存在于新创建的应用程序中。
请帮忙,如果有人需要更多详细信息,请告诉我。
更新 这些是调用的方法
- (void)tokenRequest
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShareStarted" object:nil];
[[SHKActivityIndicator currentIndicator] displayActivity:SHKLocalizedString(@"Connecting...")];
NSLog(@"Url: %@\n Token: %@ \n Consumer: %@\n Key: %@",requestURL, requestToken, consumer, consumerKey);
OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:requestURL
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:signatureProvider];
[oRequest setHTTPMethod:@"POST"];
[self tokenRequestModifyRequest:oRequest];
OAAsynchronousDataFetcher *fetcher = [OAAsynchronousDataFetcher asynchronousFetcherWithRequest:oRequest
delegate:self
didFinishSelector:@selector(tokenRequestTicket:didFinishWithData:)
didFailSelector:@selector(tokenRequestTicket:didFailWithError:)];
[fetcher start];
[oRequest release];
}
- (void)tokenRequestTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data
{
if (SHKDebugShowLogs) // check so we don't have to alloc the string with the data if we aren't logging
SHKLog(@"tokenRequestTicket Response Body: %@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
[[SHKActivityIndicator currentIndicator] hide];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SharingCancel" object:nil];
if (ticket.didSucceed)
{
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
OAToken *aToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
[responseBody release];
self.requestToken = aToken;
[aToken release];
[self tokenAuthorize];
}
else
// TODO - better error handling here
[self tokenRequestTicket:ticket didFailWithError:[SHK error:SHKLocalizedString(@"There was a problem requesting authorization from %@", [self sharerTitle])]];
}
更新 错误点
libobjc.A.dylib`objc_msgSend:
0x360a25a0: teq.w r0, #0
0x360a25a4: beq 0x360a25e6 ; objc_msgSend + 70
0x360a25a6: push.w {r3, r4}
0x360a25aa: ldr r4, [r0]
0x360a25ac: lsr.w r9, r1, #2
0x360a25b0: ldr r3, [r4, #8]
0x360a25b2: add.w r3, r3, #8
0x360a25b6: ldr r12, [r3, #-8]
0x360a25ba: and.w r9, r9, r12
0x360a25be: ldr.w r4, [r3, r9, lsl #2] //here EXC_BAD_ACCESS happened
0x360a25c2: teq.w r4, #0
0x360a25c6: add.w r9, r9, #1
0x360a25ca: beq 0x360a25e0 ; objc_msgSend + 64
0x360a25cc: ldr.w r12, [r4]
0x360a25d0: teq.w r1, r12
0x360a25d4: bne 0x360a25b6 ; objc_msgSend + 22
0x360a25d6: ldr.w r12, [r4, #8]
0x360a25da: pop.w {r3, r4}
0x360a25de: bx r12
0x360a25e0: pop.w {r3, r4}
0x360a25e4: b 0x360a2600 ; objc_msgSend_uncached
0x360a25e6: mov.w r1, #0
0x360a25ea: bx lr
0x360a25ec: nop
0x360a25ee: nop
0x360a25f0: nop
0x360a25f2: nop
0x360a25f4: nop
0x360a25f6: nop
0x360a25f8: nop
0x360a25fa: nop
0x360a25fc: nop
0x360a25fe: nop