Skip to content

Commit

Permalink
Better abstraction of settings controller responsibilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
fcanas committed Dec 17, 2012
1 parent 8cfee48 commit adbbf64
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
10 changes: 8 additions & 2 deletions FCSettingsBooster/FCBoosterCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
//

#import <Foundation/Foundation.h>
#import "FCSettingsViewController.h"

@protocol FCSettingsBoosterController <NSObject>

@property (nonatomic, strong) NSString *controllerKey;

@end


@protocol FCBoosterCell <NSObject>

Expand All @@ -18,6 +24,6 @@

@optional

- (id)valueControllerForSettingsController:(FCSettingsViewController *)settingsController;
- (id)valueControllerForSettingsController:(id<FCSettingsBoosterController>)settingsController;

@end
9 changes: 2 additions & 7 deletions FCSettingsBooster/FCColorPickerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,14 @@ - (void)setLabelText:(NSString *)labelText {
self.textLabel.text = labelText;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
// [super setSelected:selected animated:animated];
}

- (id)valueControllerForSettingsController:(FCSettingsViewController *)settingsController {
- (id)valueControllerForSettingsController:(id<FCSettingsBoosterController>)settingsController {
FCColorPickerViewController *c = [[FCColorPickerViewController alloc] initWithNibName:@"FCColorPickerViewController" bundle:nil] ;

settingsController.controllerKey = self.key;
c.color = [[NSUserDefaults standardUserDefaults] colorForKey:self.key];

if ([settingsController conformsToProtocol:@protocol(ColorPickerViewControllerDelegate)]) {
c.delegate = settingsController;
c.delegate = (id<ColorPickerViewControllerDelegate>)settingsController;
}

return c;
Expand Down
4 changes: 2 additions & 2 deletions FCSettingsBooster/FCSettingsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#import <UIKit/UIKit.h>
#import <iOS-Color-Picker/FCColorPickerViewController.h>

@interface FCSettingsViewController : UITableViewController <ColorPickerViewControllerDelegate>
#import "FCBoosterCell.h"

@property (nonatomic, strong) NSString *controllerKey;
@interface FCSettingsViewController : UITableViewController <ColorPickerViewControllerDelegate,FCSettingsBoosterController>

- (id)initWithConfiguration:(NSArray *) config andStyle:(UITableViewStyle)style;

Expand Down
6 changes: 5 additions & 1 deletion FCSettingsBooster/FCSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
#import "FCColorPickerCell.h"
#import "NSUserDefaults+UIColor.h"

@interface FCSettingsViewController ()
@interface FCSettingsViewController () {
NSString *controllerKey;
}
@property (nonatomic, strong) NSArray *configuration;
@end

@implementation FCSettingsViewController

@synthesize controllerKey=_controllerKey;

- (id)initWithConfiguration:(NSArray *) config andStyle:(UITableViewStyle)style {
self = [super initWithStyle:style];
if (self) {
Expand Down

0 comments on commit adbbf64

Please sign in to comment.