tags:

views:

338

answers:

1

I'm trying to implement http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master into my code. I'm following the Demo provided and I can't seem to get it to work. Here is where I think the problem is currently.

So the example declares a view controller that handles the OAuth Connections and such in the app delegates header like so:

app delegate header:

import uikit/uikit.h( i had to change the syntax here so that it would work )

@class OAuthTwitterDemoViewController;

@interface OAuthTwitterDemoAppDelegate : NSObject { UIWindow *window; OAuthTwitterDemoViewController *viewController; }

@property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet OAuthTwitterDemoViewController *viewController;

@end

The app delegate impl:

@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

So as you can see where the arrow is that we never do an initWithNib or plain init, we just straight add it's view to the window.

What gets called on the viewController is:

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]]]; }

}

So basically in my example this never gets called, but in the demo it does. I'm confused as to what I might need to do to get this working. I'm wondering since the viewController is an IBOutlet in the app delegates header that I may have to do something in Interface Builder, but I'm not sure what.

Any help would be appreciated!!!

A: 

We're just using the standard View Based application template for the demo; are you using that or something else? Is your OAuthTwitterDemoViewController ever getting instantiated (ie, does viewController have a value, or is it 0x0, in your applicationDidFinishLaunching:)?

It's unclear what's working in your project and what isn't. Could you clarify that a bit?

Ben Gottlieb
I used the window-based application template and added the OAuthTwitterDemoViewController.h/m files into my project. I then added code in my app delegate that mimics your app delegate for dealing with the OAuthTwitterDemoViewController.I will say at applicationDidFinishLaunching the viewController doesn't have a value. I'm not quite sure where you are instantiating OAuthTwitterDemoViewController, because in your code you are just adding the the viewController.view to the window. I'm missing something.Thank you for responding to this post and for your help.
TheGambler
Also, it's pretty neat that the author of this code answered to my post.
TheGambler
I got it to work using the viewcontroller template. I need to go back and re-learn connecting these things together it seems. Thanks for your post.
TheGambler
You're welcome! The OS instantiates the viewController from the xib file, which is why, if you're using a different template, it might not work.
Ben Gottlieb
One more question if someone wanted to have a logout feature using Twitter+Oauth would they have to remove the saved defaults somehow?
TheGambler