Twitter for iOS 5 causing app to crash on presentViewController: call

0

I have a strange problem. this method is called without any problem on the simulator but when on real device it cashes at:

[self presentViewController:twitter animated:YES completion:nil];

this is the method:

- (IBAction)DeveloperTwitter:(id)sender {
    NSString* tweet = @"some tweet goes here..";
    if ([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];        
        [twitter setInitialText:tweet];
        [self presentViewController:twitter animated:YES completion:nil];  
        twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {

            if(res == TWTweetComposeViewControllerResultDone) {

                UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"تم بنجاح" message:@"شكرا لك ، تم نشر التغريدة" delegate:self cancelButtonTitle:@"شكرًا" otherButtonTitles: nil];

                [alert show]; 
                alert = nil;   

            }
            [self dismissModalViewControllerAnimated:YES]; 
        };
    }    
    else {
        tweet = [NSString stringWithFormat:@"%@%@", @"http://twitter.com/home?status=", tweet];
        tweet = [tweet stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString: tweet]];
    }
    tweet=nil;
}

I'm calling the method from a normal UIViewController. my device is running: iOS 5.1

here is a a crash log from my device

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000102, 0x2fe9ad14
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.CPLogging.settingsQueue
Thread 0 Crashed:
0   CoreFoundation                  0x3544ee4c 0x3544d000 + 7756
1   AppSupport                      0x366f5a28 0x366d5000 + 133672
2   libdispatch.dylib               0x343957e0 0x34393000 + 10208
3   libdispatch.dylib               0x34395640 0x34393000 + 9792
4   libdispatch.dylib               0x34395260 0x34393000 + 8800
5   libdispatch.dylib               0x3439590a 0x34393000 + 10506
6   libdispatch.dylib               0x34397618 0x34393000 + 17944
7   AppSupport                      0x366f6378 0x366d5000 + 136056
8   ManagedConfiguration            0x32673a7e 0x32670000 + 14974
9   libdispatch.dylib               0x34397618 0x34393000 + 17944
10  ManagedConfiguration            0x32673aca 0x32670000 + 15050
11  ManagedConfiguration            0x32674486 0x32670000 + 17542
12  ManagedConfiguration            0x32674b8a 0x32670000 + 19338
13  FTServices                      0x37baaae4 0x37b94000 + 92900
14  FTServices                      0x37baa85c 0x37b94000 + 92252
15  FTServices                      0x37baa7de 0x37b94000 + 92126
16  libdispatch.dylib               0x34397618 0x34393000 + 17944
17  FTServices                      0x37baa78c 0x37b94000 + 92044
18  IMAVCore                        0x34709372 0x34703000 + 25458
19  IMAVCore                        0x34728716 0x34703000 + 153366
20  IMAVCore                        0x347286a2 0x34703000 + 153250
21  libdispatch.dylib               0x34397618 0x34393000 + 17944
22  IMAVCore                        0x34728650 0x34703000 + 153168
23  UIKit                           0x332d09ce 0x32f37000 + 3774926
24  UIKit                           0x332d0b7e 0x32f37000 + 3775358
25  UIKit                           0x332d0e22 0x32f37000 + 3776034
26  UIKit                           0x331ecebe 0x32f37000 + 2842302
27  UIKit                           0x3302b666 0x32f37000 + 1001062
28  UIKit                           0x330295e8 0x32f37000 + 992744
29  UIKit                           0x330283a0 0x32f37000 + 988064
30  UIKit                           0x32fb7f5a 0x32f37000 + 528218
31  UIKit                           0x32f5d494 0x32f37000 + 156820
32  UIKit                           0x32f3f0f8 0x32f37000 + 33016
33  UIKit                           0x32f3ee54 0x32f37000 + 32340
34  UIKit                           0x32f3e990 0x32f37000 + 31120
35  UIKit                           0x330d7e9a 0x32f37000 + 1707674
36  UIKit                           0x33020a18 0x32f37000 + 956952
37  UIKit                           0x32f3ba80 0x32f37000 + 19072
38  UIKit                           0x32f3cd82 0x32f37000 + 23938
39  UIKit                           0x32f3d806 0x32f37000 + 26630
40  UIKit                           0x32f3d370 0x32f37000 + 25456
41  UIKit                           0x32fd3ff6 0x32f37000 + 643062
42  UIKit                           0x3301dbfe 0x32f37000 + 945150
43  UIKit                           0x3301c360 0x32f37000 + 938848
44  ع. المسلسلات                    0x000a397a 0x9a000 + 39290
45  UIKit                           0x33074614 0x32f37000 + 1299988
46  CoreFoundation                  0x354603f6 0x3544d000 + 78838
47  UIKit                           0x32f55e00 0x32f37000 + 126464
48  UIKit                           0x32f55dbc 0x32f37000 + 126396
49  UIKit                           0x32f55d9a 0x32f37000 + 126362
50  UIKit                           0x32f55b0a 0x32f37000 + 125706
51  UIKit                           0x32f56442 0x32f37000 + 128066
52  UIKit                           0x32f54924 0x32f37000 + 121124
53  UIKit                           0x32f54312 0x32f37000 + 119570
54  UIKit                           0x32f3a68e 0x32f37000 + 13966
55  UIKit                           0x32f39f34 0x32f37000 + 12084
56  GraphicsServices                0x370f9224 0x370f4000 + 21028
57  CoreFoundation                  0x354da51c 0x3544d000 + 578844
58  CoreFoundation                  0x354da4be 0x3544d000 + 578750
59  CoreFoundation                  0x354d930c 0x3544d000 + 574220
60  CoreFoundation                  0x3545c49e 0x3544d000 + 62622
61  CoreFoundation                  0x3545c366 0x3544d000 + 62310
62  GraphicsServices                0x370f8432 0x370f4000 + 17458
63  UIKit                           0x32f68cce 0x32f37000 + 203982
64  ع. المسلسلات                    0x0009ba7c 0x9a000 + 6780
65  ع. المسلسلات                    0x0009ba20 0x9a000 + 6688
iphone
twitter
crash
asked on Stack Overflow Jun 9, 2012 by AK_ • edited Dec 10, 2013 by Kara

2 Answers

4

After hours and hours of searching I finally found a solution!

  1. This is a bug in twiiter api for iOS 5.0 (if you target your app to 5.1 it will solve it)
  2. if you still want to target your app to iOS 5.0 howver; you need to use only ascii chars in your product name key in your [product]-info.plist
  3. if you still want to use your non-ascii title as your product name use the bundle name instead (in the same plist file) !

problem solved!

I 'miserably' run into the solution in a google group after hours of searching.

source of the chat log (& Solution!)

answered on Stack Overflow Jun 10, 2012 by AK_
0

Hmmm.... I think it might be a better way to use:

self presentModalViewController:

than what you are doing right now. Also instead of using a completion handler / block try implementing the delegate methods. Look at the documentation here.

answered on Stack Overflow Jun 10, 2012 by MCKapur

User contributions licensed under CC BY-SA 3.0