我正在使用Outh将Twitter添加到我的应用中。
下面是两个分别用于登录和发布推文的UIViewControllers。
1.SettingViewcontroller 2.DetailViewcontroller
此代码用于使用SettingViewcontroller登录到twitter。
- (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");
}
}
在DetailViewcontroller中,Iam这样做是为了发布。
if(buttonIndex == 1)
{
if(detail_enginne!=nil)
{
NSLog(@"engine availble");
NSString *str=@"hai twitterrrrrrrrrrr";
[detail_enginne sendUpdate:str];
}
else{
NSLog(@"Engine not availabele");
}
}
这里我无法从DetailViewcontroller发送推文。 如何实现这一目标?
答案 0 :(得分:0)
#import "SettingViewcontroller.h"
替换
[_enginnne sendUpdate:str];
到
[[[self parentViewController] _enginnne] sendUpdate:str];