Skip to content
Browse files

Limpeza e fixes

modified:   SCTwitter/SCTwitter/SCTwitter.h
  mudei imports para o .m
  mudei as ivars para interface privada
  removi declaracao shared (nao estava sendo chamado no projeto)

modified:   SCTwitter/SCTwitter/SCTwitter.m
  mudei no metodo shared:
    - coloquei a cvar shared dentro do metodo (isso e gosto, mas acho
       que assim fica mais explicito onde esta sendo usada)
    - removi o @synchronized (o dispatch_once ja e thread safe)

modified:   SCTwitter/SCTwitterViewController.m
  removi todos os metodos vazios
  adicionei uma orientacao padrao (agora esta sem o warning)
  mudei as chamadas para a propriedade messageText
  • Loading branch information...
1 parent 6e3cad6 commit 8e89a8721be61a9802d04a10703b0defa9f1860a @mtrovilho committed
Showing with 18 additions and 52 deletions.
  1. +2 −9 SCTwitter/SCTwitter/SCTwitter.h
  2. +11 −13 SCTwitter/SCTwitter/SCTwitter.m
  3. +5 −30 SCTwitter/SCTwitterViewController.m
View
11 SCTwitter/SCTwitter/SCTwitter.h
@@ -25,9 +25,6 @@
#import <Foundation/Foundation.h>
-#import "SA_OAuthTwitterController.h"
-#import "SA_OAuthTwitterEngine.h"
-
#warning Replace these with your own app credentials
#define kConsumerKey @"D6vneoIuMP0pdBZJAV7gg"
#define kConsumerSecret @"wWc59eahiaES9ZCZ7wp28Rw4hcURG4fmIXvvwJiaR8"
@@ -39,18 +36,14 @@ typedef void(^SCTwitterStatusCallback)(BOOL success, id result);
typedef void(^SCTwitterUserCallback)(BOOL success, id result);
typedef void(^SCTwitterDirectCallback)(BOOL success, id result);
-@interface SCTwitter : NSObject <SA_OAuthTwitterEngineDelegate, SA_OAuthTwitterControllerDelegate>{
- SA_OAuthTwitterEngine *_engine;
- UIViewController *_viewController;
-}
+
+@interface SCTwitter : NSObject
@property (nonatomic, copy) SCTwitterCallback loginCallback;
@property (nonatomic, copy) SCTwitterStatusCallback statusCallback;
@property (nonatomic, copy) SCTwitterUserCallback userCallback;
@property (nonatomic, copy) SCTwitterDirectCallback directCallback;
-
-+ (SCTwitter *)shared;
+ (BOOL)isSessionValid;
+ (void)loginViewControler:(UIViewController *)aViewController callback:(void (^)(BOOL success))aCallback;
+ (void)logoutCallback:(void(^)(BOOL success))aCallback;
View
24 SCTwitter/SCTwitter/SCTwitter.m
@@ -25,8 +25,13 @@
#import "SCTwitter.h"
+#import "SA_OAuthTwitterController.h"
+#import "SA_OAuthTwitterEngine.h"
-@interface SCTwitter()
+@interface SCTwitter() <SA_OAuthTwitterEngineDelegate, SA_OAuthTwitterControllerDelegate> {
+ SA_OAuthTwitterEngine *_engine;
+ UIViewController *_viewController;
+}
- (void)loginViewControler:(UIViewController *)aViewController callback:(void (^)(BOOL success))aCallback;
- (void)logoutCallback:(void (^)(BOOL success))aCallback;
@@ -52,19 +57,12 @@ @implementation SCTwitter
#pragma mark -
#pragma mark Singleton
-static SCTwitter *_scTwitter = nil;
-+ (SCTwitter *)shared {
-
- @synchronized (self){
-
- static dispatch_once_t pred;
-
- dispatch_once(&pred, ^{
- _scTwitter = [[SCTwitter alloc] init];
- });
- }
-
++ (SCTwitter *)shared
+{
+ static dispatch_once_t pred;
+ static SCTwitter *_scTwitter = nil;
+ dispatch_once(&pred, ^{ _scTwitter = [[SCTwitter alloc] init]; });
return _scTwitter;
}
View
35 SCTwitter/SCTwitterViewController.m
@@ -12,11 +12,6 @@
@implementation SCTwitterViewController
@synthesize messageText;
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
-}
#pragma mark - View lifecycle
@@ -39,35 +34,15 @@ - (void)viewDidLoad
- (void)viewDidUnload
{
[self setMessageText:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
+ [super viewDidUnload];
}
-- (void)viewWillAppear:(BOOL)animated
-{
- [super viewWillAppear:animated];
-}
-- (void)viewDidAppear:(BOOL)animated
-{
- [super viewDidAppear:animated];
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
-}
-
-- (void)viewDidDisappear:(BOOL)animated
-{
- [super viewDidDisappear:animated];
-}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
- return NO;
+ return (UIInterfaceOrientationPortrait == interfaceOrientation);
}
#pragma mark - Button Action
@@ -96,7 +71,7 @@ - (IBAction)postBackgroundButtonAction:(id)sender
{
loadingView.hidden = NO;
- [SCTwitter postWithMessage:messageText.text callback:^(BOOL success, id result) {
+ [SCTwitter postWithMessage:self.messageText.text callback:^(BOOL success, id result) {
loadingView.hidden = YES;
NSLog(@"Message send - %i \n%@", success, result);
}];
@@ -145,7 +120,7 @@ - (IBAction)directMessageButtonAction:(id)sender
{
loadingView.hidden = NO;
- [SCTwitter directMessage:messageText.text to:nil callback:^(BOOL success, id result) {
+ [SCTwitter directMessage:self.messageText.text to:nil callback:^(BOOL success, id result) {
loadingView.hidden = YES;
if (success) {
@@ -183,7 +158,7 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField
- (void)dealloc {
- [messageText release];
+ [self setMessageText:nil];
[super dealloc];
}

0 comments on commit 8e89a87

Please sign in to comment.
Something went wrong with that request. Please try again.