Skip to content

Commit

Permalink
Added a delegate to the HPAccountManager class. It can now pass actio…
Browse files Browse the repository at this point in the history
…nsheet delegate methods to its delegate
  • Loading branch information
Sarp Erdag authored and Sarp Erdag committed Dec 19, 2012
1 parent dea03f1 commit 982ac90
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Classes/HPViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Copyright (c) 2012 Hipo. All rights reserved.
//

#import "HPAccountManager.h"

@interface HPViewController : UIViewController
@interface HPViewController : UIViewController <UIActionSheetDelegate, HPAccountManagerDelegate>

@end
7 changes: 5 additions & 2 deletions Classes/HPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "HPViewController.h"
#import "HPAccount.h"
#import "HPAccountManager.h"


@interface HPViewController ()
Expand All @@ -20,7 +19,7 @@ @implementation HPViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[HPAccountManager sharedManager].delegate = self;
}

- (IBAction)didTapTwitterLoginButton {
Expand All @@ -45,4 +44,8 @@ - (IBAction)didTapFacebookLoginButton {
}];
}

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"Action sheet dismissed");
}

@end
5 changes: 5 additions & 0 deletions Dependencies/HPAccountManager/HPAccountManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ typedef enum {

@class TWAPIManager;

@protocol HPAccountManagerDelegate <UIActionSheetDelegate>
@end

@interface HPAccountManager : NSObject <UIActionSheetDelegate> {
@private
TWAPIManager *_twitterManager;
Expand All @@ -38,13 +41,15 @@ typedef enum {
NSArray *_facebookPermissions;

HPAccountAuthHandler _authHandler;
id <HPAccountManagerDelegate> _delegate;
}

@property (nonatomic, readonly) NSString *twitterUsername;
@property (nonatomic, readonly) NSString *twitterToken;
@property (nonatomic, readonly) NSString *twitterTokenSecret;
@property (nonatomic, readonly) NSString *facebookToken;
@property (nonatomic, readonly, retain) ACAccount *twitterAccount;
@property (nonatomic , unsafe_unretained) id <HPAccountManagerDelegate> delegate;

+ (HPAccountManager *)sharedManager;

Expand Down
4 changes: 4 additions & 0 deletions Dependencies/HPAccountManager/HPAccountManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ - (id)init {
self = [super init];

if (self) {

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveApplicationWillTerminateNotification:)
name:UIApplicationWillTerminateNotification
Expand Down Expand Up @@ -532,6 +533,9 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger

[self generateTokenForTwitterAccount:[systemTwitterAccounts objectAtIndex:buttonIndex]];
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
[self.delegate actionSheet:actionSheet didDismissWithButtonIndex:buttonIndex];
}

#pragma mark - Completion

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,4 @@
<Bucket
type = "1"
version = "1.0">
<FileBreakpoints>
<FileBreakpoint
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HPSocialNetworkManager/HPViewController.m"
timestampString = "376232772.411982"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "28"
endingLineNumber = "28"
landmarkName = "-didTapTwitterLoginButton"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
</Bucket>

0 comments on commit 982ac90

Please sign in to comment.