Home Articles

iOS Post Twitter Media崩溃

Asked
Viewed 1149 times
0

我试图将我的应用程序中的图片发布到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 exceptionPreprocess + 130 1 libobjc.A.dylib 0x38085ce7 objc_exception_throw + 38 2 CoreFoundation 0x2d8ee7f7 -[NSObject(NSObject) doesNotRecognizeSelector:] + 202 3 CoreFoundation 0x2d8ed0f7 __forwarding 706 4的CoreFoundation 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 CoreFoundation 0x2d8b5641 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 8 10的CoreFoundation 0x2d8b3f0d __CFRunLoopRun 1308 11的CoreFoundation 0x2d81e729 CFRunLoopRunSpecific 524 12的CoreFoundation 0x2d81e50b CFRunLoopRunInMode 106个13 GraphicsServices 0x3278d6d3 GSEventRunModal 138 14的UIKit 0x3017f871 UIApplicationMain 1136 15 MyApp 0x000edabf main(main.m:16)16 libdyld.dylib 0x38583ab7 start 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

1 Answer

  • 0

    我终于碰巧创建了一个简单的应用程序,只使用用户的Twitter帐户发布媒体 . 我能够解决这个问题,这是因为Expired Token . 用户的Twitter凭据不再准确 . 当他在“设置”中点击他的Twitter帐户时,我们得到了警告来证明这一点 . 一旦他重新进入警报,一切都开始起作用了 . 现在它也适用于我的主应用程序 .

    感谢大家!

Related