【发布时间】:2011-05-19 14:01:30
【问题描述】:
我正在尝试在我的代码中实现http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master。我正在关注提供的演示,但我似乎无法让它工作。这就是我认为目前的问题所在。
因此,该示例声明了一个处理 OAuth 连接的视图控制器,并且在应用程序委托标头中,如下所示:
应用委托标头:
#import <uikit/uikit.h>
@class OAuthTwitterDemoViewController;
@interface OAuthTwitterDemoAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
OAuthTwitterDemoViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet OAuthTwitterDemoViewController *viewController;
@end
应用委托实现:
@implementation OAuthTwitterDemoAppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:viewController.view]; <------------------------
[window makeKeyAndVisible];
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
所以你可以看到箭头所在的位置,我们从不执行 initWithNib 或普通 init,我们只是直接将它的视图添加到窗口。
在 viewController 上调用的是:
OAuthTwitterDemoViewController
- (void) viewDidAppear: (BOOL)animated {
if (_engine) return;
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
_engine.consumerKey = kOAuthConsumerKey;
_engine.consumerSecret = kOAuthConsumerSecret;
[_engine requestRequestToken];
UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
if (controller)
[self presentModalViewController: controller animated: YES];
else {
[_engine sendUpdate: [NSString stringWithFormat: @"Already Updated. %@", [NSDate date]]];
}
}
所以基本上在我的示例中它永远不会被调用,但在演示中它确实如此。我很困惑我可能需要做什么才能让它工作。我想知道,因为 viewController 是应用程序委托标头中的 IBOutlet,我可能必须在 Interface Builder 中做一些事情,但我不确定是什么。
任何帮助将不胜感激!!!
【问题讨论】:
-
twitter oauth 中的签名是什么?
标签: iphone