2012-11-09 118 views
0

在我的iPhone應用程序中,我正在使用ShareKit實現twitter共享功能。當我試圖通過設備上的twitter分享時,該應用程序崩潰在嘗試連接ios中的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  
+1

提供有關如何ü執行更多的信息 - (空)connectionDidFinishLoading:(NSURLConnection的*)aConnection ... – lakesh

+0

我加入了一些代碼,請檢查。 – Mithuzz

回答

0

ShareKit將嘗試使用導航控制器堆棧findroot view controller方法,那麼pop一個modal view controller從那裏。它拋出這個error,當它不能find之一。

您可以通過manuallycorrect它通過使用下面的調用設置root view controller

[SHK setRootViewController:myViewController]; 

檢查answer

+0

我試圖通過在鏈接的答案中使用[SHK setRootViewController:myViewController],但仍然是相同的錯誤。 – Mithuzz

+0

而且它在模擬器中工作正常,問題只在設備中。 – Mithuzz

+0

http://stackoverflow.com/a/6263181/1106035 –

相關問題