0

In my iOS app, i am trying to send Tweet once sending the SMS. what the problem here is it shows the sms screen and tap send button then the control comes to my "Send Tweet" method but it is not showing the "Tweet" Sending Screen.

And when i call my "Send Tweet" method without calling the sms sending functions , it works and shows the tweet sending screen.but why is not showing the tweet sending screen after sending the sms.

//================================================================================= 
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller
didFinishWithResult:(MessageComposeResult)result {
    //================================================================================= 
    switch (result)
    {

        case MessageComposeResultCancelled:
            NSLog(@"Result: canceled");
            break;
        case MessageComposeResultSent:
            NSLog(@"Result: sent");
            [self logSMSSentInfo];
            break;
        case MessageComposeResultFailed:
            NSLog(@"Result: failed");
            break;
        default:
            NSLog(@"Result: not sent");
            break;
    }

   [self dismissModalViewControllerAnimated:YES];

   [self performSelectorOnMainThread:@selector(SendTweet) withObject:nil waitUntilDone:NO];


}

// this function is to send tweet
//============================================
-(void)sendTweet:(NSString*)inTweetAccountInfo{
//============================================

    if ([TWTweetComposeViewController canSendTweet])
     {
     NSString *aTweetMsg;
        }
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
user198725878
  • 6,266
  • 18
  • 77
  • 135

2 Answers2

0

The problem that you want to perform on main thread on the current object, but your object will be released once you call [self dismissModalViewControllerAnimated:YES];

So you need to pass the sendTweet method to a living object.

Edit:

You can implement a delegate protocol and tell to the viewController that presents your modalView to sendTweet( the send tweet method have to be in the parentViewController).

Alex Terente
  • 12,006
  • 5
  • 51
  • 71
0

Why don't you use a Notification Center instead of performSelectorOnMainThread as described here. In case you need more details about Notification Center you might like to look here. I hope this helps.

Community
  • 1
  • 1
antf
  • 3,162
  • 2
  • 26
  • 33