diff --git a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m index 0a6f5e4..21bf1a3 100644 --- a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m +++ b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m @@ -61,6 +61,7 @@ + (BOOL) credentialEntryRequiredWithTwitterEngine: (SA_OAuthTwitterEngine *) eng - (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation { if (self = [super init]) { self.engine = engine; + if (!engine.OAuthSetup) [_engine requestRequestToken]; self.orientation = theOrientation; _firstLoad = YES; @@ -76,7 +77,6 @@ - (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterf if ([_webView respondsToSelector: @selector(setDataDetectorTypes:)]) [(id) _webView setDataDetectorTypes: 0]; NSURLRequest *request = _engine.authorizeURLRequest; - [_webView loadRequest: request]; } return self; diff --git a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.h b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.h old mode 100755 new mode 100644 index 0d41a8c..eb43268 --- a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.h +++ b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.h @@ -40,7 +40,7 @@ @property (nonatomic, readwrite, retain) NSString *consumerSecret, *consumerKey; @property (nonatomic, readwrite, retain) NSURL *requestTokenURL, *accessTokenURL, *authorizeURL; //you shouldn't need to touch these. Just in case... - +@property (nonatomic, readonly) BOOL OAuthSetup; + (SA_OAuthTwitterEngine *) OAuthTwitterEngineWithDelegate: (NSObject *) delegate; - (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate; diff --git a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.m b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.m old mode 100755 new mode 100644 index 47ec989..3364c3f --- a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.m +++ b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterEngine.m @@ -70,12 +70,14 @@ - (SA_OAuthTwitterEngine *) initOAuthWithDelegate: (NSObject *) delegate { //============================================================================================================================= #pragma mark OAuth Code +- (BOOL) OAuthSetup { + return _consumer != nil; +} - (OAConsumer *) consumer { if (_consumer) return _consumer; NSAssert(self.consumerKey.length > 0 && self.consumerSecret.length > 0, @"You must first set your Consumer Key and Consumer Secret properties. Visit http://twitter.com/oauth_clients/new to obtain these."); _consumer = [[OAConsumer alloc] initWithKey: self.consumerKey secret: self.consumerSecret]; - return _consumer; } @@ -124,14 +126,19 @@ - (void) clearAccessToken { if ([_delegate respondsToSelector: @selector(storeCachedTwitterOAuthData:forUsername:)]) [(id) _delegate storeCachedTwitterOAuthData: @"" forUsername: self.username]; [_accessToken release]; _accessToken = nil; + [_consumer release]; + _consumer = nil; + self.pin = nil; + [_requestToken release]; + _requestToken = nil; } - (void) setPin: (NSString *) pin { [_pin autorelease]; _pin = [pin retain]; - if (pin.length) _accessToken.pin = pin; - if (pin.length) _requestToken.pin = pin; + _accessToken.pin = pin; + _requestToken.pin = pin; } //=============================================================================================================================