简体   繁体   English

尝试在iOS中连接Twitter时应用崩溃

[英]App crashes when tries to connect twitter in ios

In my iPhone app i am implementing the twitter share feature using ShareKit. 在我的iPhone应用程序中,我正在使用ShareKit实现Twitter共享功能。 When I tried to share via twitter in device, the app is crashing at 当我尝试通过设备中的Twitter分享时,该应用程序在崩溃

- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection

And I got the error message; 我得到了错误信息;

NSInvalidArgumentException, [NSCFType tokenRequestTicket:didFinishWithData]:

But it is running fine on simulator. 但是它在模拟器上运行良好。 And I used the same code without any change in another application before, and it is still running fine. 我以前使用相同的代码,而未在其他应用程序中进行任何更改,并且它仍然可以正常运行。 The issue is only in newly created app. 该问题仅在新创建的应用中。

Please help, and if somebody need more details please let me know. 请提供帮助,如果有人需要更多详细信息,请告诉我。

Update These are methods called 更新这些是称为

 - (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])]];
}

Update Error point 更新错误点

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    

ShareKit will try to use the navigation controller stack to find your root view controller , then pop a modal view controller from there. ShareKit将尝试使用导航控制器堆栈find您的root view controller ,然后从那里pop一个modal view controller It throws this error when it can't find one. find它时,它将引发此error

You can correct it by manually setting the root view controller by using the following call: 您可以通过使用以下调用manually设置root view controllercorrect它:

[SHK setRootViewController:myViewController];

Check answer . 检查答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM