I am Using Outh to add Twitter to my app.
Below are two UIViewControllers for login and posting tweets respectively.
1.SettingViewcontroller 2.DetailViewcontroller
This code for login to twitter with SettingViewcontroller.
- (void)switchAction1:(UISwitch*)sender
{
if (sender.on){
if(_engine)
return;
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self]
_engine.consumerKey = @"###";
_engine.consumerSecret = @"###";
UIViewController *controller =[SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
DetailViewcontroller *detobj=[[DetailViewcontroller alloc]init];
detobj.detail_enginne=_engine;
[detobj release];
[self presentModalViewController: controller animated: YES];
}
if(!sender.on)
{
NSLog(@"Logout section");
}
}
And In DetailViewcontroller Iam doin开发者_运维知识库g like this for posting.
if(buttonIndex == 1)
{
if(detail_enginne!=nil)
{
NSLog(@"engine availble");
NSString *str=@"hai twitterrrrrrrrrrr";
[detail_enginne sendUpdate:str];
}
else{
NSLog(@"Engine not availabele");
}
}
Here Iam unable to send tweets from DetailViewcontroller. How to achive this?
in DetailViewcontroller.m
#import "SettingViewcontroller.h"
replace
[_enginnne sendUpdate:str];
to
[[[self parentViewController] _enginnne] sendUpdate:str];
精彩评论