0

My app works on a device with 5.1 (ipad). But it crashed on 6.0 simulator. Please, see an error.

@interface TwitterViewController : TWTweetComposeViewController

@property (weak, nonatomic) id<TwitterVCDelegate> delegateTwitter;

@end

//In QuotesVC I call

TwitterViewController *tweetVC = [[TwitterViewController alloc] init];
tweetVC.delegateTwitter = self;
[tweetVC postWithQuote:[quotesArray objectAtIndex:currentIndex]];

// my app has crashed

-[SLTwitterComposeViewController setDelegateTwitter:]: unrecognized selector sent to instance 0xa8d1bb0
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SLTwitterComposeViewController setDelegateTwitter:]: unrecognized selector sent to instance 0xa8d1bb0'
 libc++abi.dylib: terminate called throwing an exception

Edit Everything works well If I doesn't inherit TWTweetComposeViewController.

   TWTweetComposeViewController *tweetSheet =
    [[TWTweetComposeViewController alloc] init];
    [tweetSheet setInitialText:@"Initial Tweet Text!"];
    [self presentModalViewController:tweetSheet animated:YES];

I tested this code on ipad device 5.1 and ios simulator 6.0. It works well.

Is it permited to inherit TWTweetComposeViewController?

Voloda2
  • 12,359
  • 18
  • 80
  • 130

2 Answers2

1

On my mind iOS 6 implicitly convert TWTweetComposeViewController to SLTwitterComposeViewController. SLTwitterComposeViewController don't have any setDelegateTwitter: method. That's why error occured.

IMHO

Dinesh Raja
  • 8,501
  • 5
  • 42
  • 81
Voloda2
  • 12,359
  • 18
  • 80
  • 130
0

Your code will work in iOS 5 versions. Because you have included twitter.framework and it will be replaced as a social.framework. So you need to check whether the device is iOS 6 or 5. Here it is a links to integrate twitter for versions iOS 5 and iOS 6.

iOS 6 Social framework

iOS 5 Twitter framework

Dinesh Raja
  • 8,501
  • 5
  • 42
  • 81
  • If I add social.framework to my app I won't run on ios 5.1 device, because it hasn't this framework. – Voloda2 Nov 04 '12 at 08:19
  • http://stackoverflow.com/questions/6480765/how-do-i-weak-link-frameworks-on-xcode-4 http://stackoverflow.com/questions/7778104/problems-building-for-both-ios4-3-and-ios5-0 these links will be helpful to u. you need to set both frameworks as optional – Dinesh Raja Nov 04 '12 at 09:14
  • yes I tried. It's impossible to inherit SLComposeViewController because it doesn't allow to do this. serviceType is readOnly. I refactored my code and now I don't inherit twitter's classes. Thank you for help. – Voloda2 Nov 05 '12 at 21:21