【发布时间】:2014-09-28 17:54:33
【问题描述】:
我正在尝试将我的应用中的图片发布到 Twitter 帐户。它在我的 3 台设备上运行良好,但我的一位朋友崩溃了。我正在使用以下代码。到目前为止,它浪费了将近 2 天,没有任何运气。请参阅问题行,根据 crashalytics,应用程序在这两行上崩溃。有人经历过吗?
NSString *account_id = [PFUser currentUser][@"Twitter_ScreenName"];
NSURL *retweetURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update_with_media.json"];
//Problem
NSDictionary *params = @{@"status" : [NSString stringWithFormat:@"%@#mytag",self.postTextView.text]};
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:retweetURL
parameters:params];
NSData *imageData = UIImageJPEGRepresentation(self.postImage, 0.5f);
[request addMultipartData:imageData withName:@"media[]" type:@"image/jpeg" filename:@"image.jpg"];
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error)
{
if (granted == YES)//Problem
{
NSArray *twitterAccounts =
[account accountsWithAccountType:accountType];
if ([twitterAccounts count] > 0)
{
ACAccount *twitterAccount;
for (int i=0; i<[twitterAccounts count]; i++)
{
ACAccount *acc=[twitterAccounts objectAtIndex:i];
if ([acc.username isEqualToString: account_id ])
{
twitterAccount = acc;
break;
}
}
崩溃日志: 线程:致命异常:NSInvalidArgumentException 0 CoreFoundation 0x2d8eaecb 异常预处理 + 130 1 libobjc.A.dylib 0x38085ce7 objc_exception_throw + 38 2核心基础0x2d8ee7f7-[NSObject(NSObject)不识别选择器:]+202 3 核心基础 0x2d8ed0f7 ___forwarding_ + 706 4 核心基础 0x2d83c058 _CF_forwarding_prep_0 + 24 5 MyApp 0x0011d425 44-[HMTagListViewController buttonAddClicked:]_block_invoke_3 (HMTagListViewController.m:2475) 6 libdispatch.dylib 0x38574b3b _dispatch_barrier_sync_f_slow_invoke + 70 7 libdispatch.dylib 0x3856ed3f _dispatch_client_callout + 22 8 libdispatch.dylib 0x385716c3 _dispatch_main_queue_callback_4CF + 278 9 核心基础 0x2d8b5641 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 8 10 核心基础 0x2d8b3f0d __CFRunLoopRun + 1308 11 核心基础 0x2d81e729 CFRunLoopRunSpecific + 524 12 核心基础 0x2d81e50b CFRunLoopRunInMode + 106 13 图形服务 0x3278d6d3 GSEventRunModal + 138 14 UIKit 0x3017f871 UIApplicationMain + 1136 15 MyApp 0x000edabf 主 (main.m:16) 16 libdyld.dylib 0x38583ab7 开始 + 2
=====================
线程:SLRequest performRequest 队列 0 libsystem_kernel.dylib 0x38627aa0 semaphore_wait_trap + 8 1 libsystem_platform.dylib 0x3869ba0d _os_semaphore_wait + 12 2 libdispatch.dylib 0x38573513 _dispatch_barrier_sync_f_slow + 138 3 MyApp 0x0011d31b __44-[HMTagListViewController buttonAddClicked:]_block_invoke_21179 (HMTagListViewController.m:2461) 4 社交 0x2ff74267 __39-[SLRequest performRequestWithHandler:]_block_invoke + 410 5 libdispatch.dylib 0x3856ed53 _dispatch_call_block_and_release + 10 6 libdispatch.dylib 0x38573cbd _dispatch_queue_drain + 488 7 libdispatch.dylib 0x38570c6f _dispatch_queue_invoke + 42 8 libdispatch.dylib 0x385745f1 _dispatch_root_queue_drain + 76 9 libdispatch.dylib 0x385748dd _dispatch_worker_thread2 + 56 10 libsystem_pthread.dylib 0x3869fc17 _pthread_wqthread + 298
【问题讨论】:
-
所以你基本上知道哪一行但似乎不想调试那一行。它可以很容易地分成三个语句,因此可以确定问题出在哪里。添加 NSLog() 语句。你为什么不这样做!堆栈跟踪确切的完整(复制/粘贴)错误消息在哪里?
-
Zaph.. 要么尝试帮助人们,要么继续前进。你不必用烦人的感叹号来教训别人。我不能做一个 nslog,因为它不是发生在我的设备上,而是发生在我无法访问代码的朋友身上。别再浪费时间了!!!
-
为您的朋友创建一个具有更多调试功能的版本,让那个人与您一起工作。如果您不结合语句,错误报告会更清楚地指出问题所在。错误信息在哪里?
-
什么是崩溃消息,具体是哪一行?
标签: ios objective-c twitter crash