Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Commit

Permalink
3.0.0-alpha.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed Aug 28, 2015
1 parent 4180eb9 commit a30fc70
Show file tree
Hide file tree
Showing 41 changed files with 1,002 additions and 628 deletions.
2 changes: 1 addition & 1 deletion Bohr.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Bohr"
s.version = "2.1.0"
s.version = "3.0.0-alpha.1"
s.summary = "Settings screen composing framework"
s.homepage = "https://github.com/DavdRoman/Bohr"
s.author = { "David Román" => "d@vidroman.me" }
Expand Down
61 changes: 50 additions & 11 deletions Bohr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
754E568A1B1DFDB400075B6E /* BOSetting.m in Sources */ = {isa = PBXBuildFile; fileRef = 754E56881B1DFDB400075B6E /* BOSetting.m */; };
754E568D1B1FC16700075B6E /* BOSwitchTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 754E568B1B1FC16700075B6E /* BOSwitchTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
754E568E1B1FC16700075B6E /* BOSwitchTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 754E568C1B1FC16700075B6E /* BOSwitchTableViewCell.m */; };
7599AF461B2B29E000B253CD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7599AF451B2B29E000B253CD /* Main.storyboard */; };
759E1B001B2BC31700AD8F38 /* BOTimeTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 754E56931B2083DE00075B6E /* BOTimeTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
759E1B011B2BC31700AD8F38 /* BOTimeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 754E56941B2083DE00075B6E /* BOTimeTableViewCell.m */; };
75B6CE1C1B3756D800DADCBD /* BOOptionTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 75B6CE1A1B3756D800DADCBD /* BOOptionTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -35,6 +34,15 @@
75E19B451B2BC76100C03FF6 /* BOChoiceTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 754E56A31B20D2FE00075B6E /* BOChoiceTableViewCell.m */; };
75E19B461B2BCCFE00C03FF6 /* BOTextTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E02FE11B21F72C009698D3 /* BOTextTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; };
75E19B471B2BCCFE00C03FF6 /* BOTextTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 75E02FE21B21F72C009698D3 /* BOTextTableViewCell.m */; };
D5CF66461B8DFAC800FC5F13 /* BOTableViewSection.h in Headers */ = {isa = PBXBuildFile; fileRef = D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */; settings = {ATTRIBUTES = (Public, ); }; };
D5CF66471B8DFAC800FC5F13 /* BOTableViewSection.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */; };
D5CF664C1B8DFF4700FC5F13 /* MZAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */; settings = {ATTRIBUTES = (Public, ); }; };
D5CF664D1B8DFF4700FC5F13 /* MZAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CF66491B8DFF4700FC5F13 /* MZAppearance.m */; };
D5CF664E1B8DFF4700FC5F13 /* NSInvocation+Copy.h in Headers */ = {isa = PBXBuildFile; fileRef = D5CF664A1B8DFF4700FC5F13 /* NSInvocation+Copy.h */; };
D5CF664F1B8DFF4700FC5F13 /* NSInvocation+Copy.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CF664B1B8DFF4700FC5F13 /* NSInvocation+Copy.m */; };
D5CF66521B8E491A00FC5F13 /* UIColor+Bohr.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CF66511B8E491A00FC5F13 /* UIColor+Bohr.m */; };
D5D00B6E1B8FD14500ADCAB2 /* OptionsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5D00B6D1B8FD14500ADCAB2 /* OptionsTableViewController.m */; };
D5D00B721B8FE63E00ADCAB2 /* BOTableViewCell+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5D00B711B8FE63E00ADCAB2 /* BOTableViewCell+Private.h */; };
D5F1D8A91B3A1EF1004DA018 /* BOTableViewController+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5F1D8A81B3A1EF1004DA018 /* BOTableViewController+Private.h */; };
D5F1D8AB1B3A210E004DA018 /* BOSetting+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D5F1D8AA1B3A210E004DA018 /* BOSetting+Private.h */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -75,7 +83,6 @@
754E56981B20C9D400075B6E /* BOButtonTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOButtonTableViewCell.m; sourceTree = "<group>"; };
754E56A21B20D2FE00075B6E /* BOChoiceTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOChoiceTableViewCell.h; sourceTree = "<group>"; };
754E56A31B20D2FE00075B6E /* BOChoiceTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOChoiceTableViewCell.m; sourceTree = "<group>"; };
7599AF451B2B29E000B253CD /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
75B6CE1A1B3756D800DADCBD /* BOOptionTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOOptionTableViewCell.h; sourceTree = "<group>"; };
75B6CE1B1B3756D800DADCBD /* BOOptionTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOOptionTableViewCell.m; sourceTree = "<group>"; };
75C7ADD31B1AB3010050C8AA /* BohrDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BohrDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -96,6 +103,17 @@
75C7AE261B1AB42A0050C8AA /* BOTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTableViewCell.m; sourceTree = "<group>"; };
75E02FE11B21F72C009698D3 /* BOTextTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOTextTableViewCell.h; sourceTree = "<group>"; };
75E02FE21B21F72C009698D3 /* BOTextTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTextTableViewCell.m; sourceTree = "<group>"; };
D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BOTableViewSection.h; sourceTree = "<group>"; };
D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BOTableViewSection.m; sourceTree = "<group>"; };
D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZAppearance.h; sourceTree = "<group>"; };
D5CF66491B8DFF4700FC5F13 /* MZAppearance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZAppearance.m; sourceTree = "<group>"; };
D5CF664A1B8DFF4700FC5F13 /* NSInvocation+Copy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSInvocation+Copy.h"; sourceTree = "<group>"; };
D5CF664B1B8DFF4700FC5F13 /* NSInvocation+Copy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+Copy.m"; sourceTree = "<group>"; };
D5CF66501B8E491A00FC5F13 /* UIColor+Bohr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Bohr.h"; sourceTree = "<group>"; };
D5CF66511B8E491A00FC5F13 /* UIColor+Bohr.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Bohr.m"; sourceTree = "<group>"; };
D5D00B6C1B8FD14500ADCAB2 /* OptionsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsTableViewController.h; sourceTree = "<group>"; };
D5D00B6D1B8FD14500ADCAB2 /* OptionsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OptionsTableViewController.m; sourceTree = "<group>"; };
D5D00B711B8FE63E00ADCAB2 /* BOTableViewCell+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BOTableViewCell+Private.h"; sourceTree = "<group>"; };
D5F1D8A81B3A1EF1004DA018 /* BOTableViewController+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BOTableViewController+Private.h"; sourceTree = "<group>"; };
D5F1D8AA1B3A210E004DA018 /* BOSetting+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BOSetting+Private.h"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -142,9 +160,12 @@
children = (
75C7ADDA1B1AB3010050C8AA /* AppDelegate.h */,
75C7ADDB1B1AB3010050C8AA /* AppDelegate.m */,
7599AF451B2B29E000B253CD /* Main.storyboard */,
D5CF66501B8E491A00FC5F13 /* UIColor+Bohr.h */,
D5CF66511B8E491A00FC5F13 /* UIColor+Bohr.m */,
75C7ADDD1B1AB3010050C8AA /* TableViewController.h */,
75C7ADDE1B1AB3010050C8AA /* TableViewController.m */,
D5D00B6C1B8FD14500ADCAB2 /* OptionsTableViewController.h */,
D5D00B6D1B8FD14500ADCAB2 /* OptionsTableViewController.m */,
75C7ADD61B1AB3010050C8AA /* Supporting Files */,
);
path = BohrDemo;
Expand All @@ -168,8 +189,11 @@
75C7AE1F1B1AB3480050C8AA /* BOTableViewController.h */,
75C7AE201B1AB3480050C8AA /* BOTableViewController.m */,
D5F1D8A81B3A1EF1004DA018 /* BOTableViewController+Private.h */,
D5CF66441B8DFAC800FC5F13 /* BOTableViewSection.h */,
D5CF66451B8DFAC800FC5F13 /* BOTableViewSection.m */,
75C7AE251B1AB42A0050C8AA /* BOTableViewCell.h */,
75C7AE261B1AB42A0050C8AA /* BOTableViewCell.m */,
D5D00B711B8FE63E00ADCAB2 /* BOTableViewCell+Private.h */,
754E564F1B1B461700075B6E /* BOTableViewCell+Subclass.h */,
754E568B1B1FC16700075B6E /* BOSwitchTableViewCell.h */,
754E568C1B1FC16700075B6E /* BOSwitchTableViewCell.m */,
Expand All @@ -186,6 +210,10 @@
754E56871B1DFDB400075B6E /* BOSetting.h */,
754E56881B1DFDB400075B6E /* BOSetting.m */,
D5F1D8AA1B3A210E004DA018 /* BOSetting+Private.h */,
D5CF66481B8DFF4700FC5F13 /* MZAppearance.h */,
D5CF66491B8DFF4700FC5F13 /* MZAppearance.m */,
D5CF664A1B8DFF4700FC5F13 /* NSInvocation+Copy.h */,
D5CF664B1B8DFF4700FC5F13 /* NSInvocation+Copy.m */,
75C7AE011B1AB3280050C8AA /* Supporting Files */,
);
path = Bohr;
Expand Down Expand Up @@ -213,7 +241,11 @@
75C7AE211B1AB3480050C8AA /* BOTableViewController.h in Headers */,
75E19B441B2BC76100C03FF6 /* BOChoiceTableViewCell.h in Headers */,
754E56891B1DFDB400075B6E /* BOSetting.h in Headers */,
D5CF66461B8DFAC800FC5F13 /* BOTableViewSection.h in Headers */,
D5CF664C1B8DFF4700FC5F13 /* MZAppearance.h in Headers */,
754E568D1B1FC16700075B6E /* BOSwitchTableViewCell.h in Headers */,
D5D00B721B8FE63E00ADCAB2 /* BOTableViewCell+Private.h in Headers */,
D5CF664E1B8DFF4700FC5F13 /* NSInvocation+Copy.h in Headers */,
75B6CE1C1B3756D800DADCBD /* BOOptionTableViewCell.h in Headers */,
75C7AE291B1AB42A0050C8AA /* BOTableViewCell.h in Headers */,
759E1B001B2BC31700AD8F38 /* BOTimeTableViewCell.h in Headers */,
Expand Down Expand Up @@ -268,15 +300,15 @@
75C7ADC91B1AB2F80050C8AA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0630;
LastUpgradeCheck = 0640;
TargetAttributes = {
75C7ADD21B1AB3010050C8AA = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = 928NVD8D9L;
DevelopmentTeam = 26CPNYHDUU;
};
75C7ADFE1B1AB3280050C8AA = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = 928NVD8D9L;
DevelopmentTeam = 26CPNYHDUU;
};
};
};
Expand Down Expand Up @@ -304,7 +336,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7599AF461B2B29E000B253CD /* Main.storyboard in Resources */,
75C7ADE71B1AB3010050C8AA /* LaunchScreen.xib in Resources */,
75C7ADE41B1AB3010050C8AA /* Images.xcassets in Resources */,
);
Expand All @@ -324,9 +355,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D5CF66521B8E491A00FC5F13 /* UIColor+Bohr.m in Sources */,
75C7ADDF1B1AB3010050C8AA /* TableViewController.m in Sources */,
75C7ADDC1B1AB3010050C8AA /* AppDelegate.m in Sources */,
75C7ADD91B1AB3010050C8AA /* main.m in Sources */,
D5D00B6E1B8FD14500ADCAB2 /* OptionsTableViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -338,11 +371,14 @@
75C7AE221B1AB3480050C8AA /* BOTableViewController.m in Sources */,
754E568A1B1DFDB400075B6E /* BOSetting.m in Sources */,
75B6CE1F1B375DCA00DADCBD /* BOButtonTableViewCell.m in Sources */,
D5CF66471B8DFAC800FC5F13 /* BOTableViewSection.m in Sources */,
754E568E1B1FC16700075B6E /* BOSwitchTableViewCell.m in Sources */,
759E1B011B2BC31700AD8F38 /* BOTimeTableViewCell.m in Sources */,
D5CF664D1B8DFF4700FC5F13 /* MZAppearance.m in Sources */,
75B6CE1D1B3756D800DADCBD /* BOOptionTableViewCell.m in Sources */,
75E19B471B2BCCFE00C03FF6 /* BOTextTableViewCell.m in Sources */,
75E19B451B2BC76100C03FF6 /* BOChoiceTableViewCell.m in Sources */,
D5CF664F1B8DFF4700FC5F13 /* NSInvocation+Copy.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -371,12 +407,15 @@
75C7ADCD1B1AB2F80050C8AA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
75C7ADCE1B1AB2F80050C8AA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
};
name = Release;
};
Expand Down Expand Up @@ -419,7 +458,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = BohrDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -463,7 +502,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = BohrDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -518,7 +557,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Bohr/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -570,7 +609,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Bohr/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
2 changes: 1 addition & 1 deletion Bohr.xcodeproj/xcshareddata/xcschemes/Bohr.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 2 additions & 8 deletions Bohr/BOButtonTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@

@interface BOButtonTableViewCell : BOTableViewCell

/// The target of the cell action.
@property (nonatomic) id target;

/// The action defined by the cell, triggered when it's tapped.
@property (nonatomic) SEL action;

/// Sets both the target and action for the cell to be performed.
- (void)setTarget:(id)target action:(SEL)action;
/// A block defining the cell action when it's pressed.
@property (nonatomic, copy) void (^actionBlock)(void);

@end
11 changes: 1 addition & 10 deletions Bohr/BOButtonTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ - (void)setup {
self.textLabel.textAlignment = NSTextAlignmentCenter;
}

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
if ([self.target respondsToSelector:self.action]) {
[self.target performSelector:self.action];
}
}

- (void)setTarget:(id)target action:(SEL)action {
self.target = target;
self.action = action;
if (self.actionBlock) self.actionBlock();
}

@end
6 changes: 3 additions & 3 deletions Bohr/BOChoiceTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

@interface BOChoiceTableViewCell : BOTableViewCell

/// An array defining (in short) all the options availables on the cell.
@property (nonatomic, strong) NSArray *options;
/// An array defining all the options available for the cell.
@property (nonatomic) NSArray *options;

/// An array defining all the footer titles for each option assigned to the cell.
@property (nonatomic, strong) IBInspectable NSArray *footerTitles;
@property (nonatomic) NSArray *footerTitles;

@end
2 changes: 1 addition & 1 deletion Bohr/BOChoiceTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (NSString *)footerTitle {
return self.footerTitles[currentOption];
}

return [super footerTitle];
return nil;
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
Expand Down
2 changes: 1 addition & 1 deletion Bohr/BOOptionTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
@interface BOOptionTableViewCell : BOTableViewCell

/// The string for the footer title when the cell has a checkmark on it.
@property (nonatomic, strong) IBInspectable NSString *footerTitle;
@property (nonatomic) NSString *footerTitle;

@end
10 changes: 2 additions & 8 deletions Bohr/BOOptionTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ - (void)setup {
}

- (void)wasSelectedFromViewController:(BOTableViewController *)viewController {
NSInteger optionIndex = [viewController.tableView indexPathForCell:self].row;
self.setting.value = @(optionIndex);
self.setting.value = @(self.indexPath.row);
}

- (void)settingValueDidChange {
NSInteger optionIndex = [self.setting.value integerValue];

if (optionIndex == self.indexPath.row) {
self.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
self.accessoryType = UITableViewCellAccessoryNone;
}
self.accessoryType = (optionIndex == self.indexPath.row) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
}

@end
4 changes: 1 addition & 3 deletions Bohr/BOSetting+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

@interface BOSetting ()

typedef void(^BOSettingValueDidChangeBlock)(void);

@property (nonatomic, copy) BOSettingValueDidChangeBlock valueDidChangeBlock;
@property (nonatomic, copy) void(^valueDidChangeBlock)(void);

@end
23 changes: 15 additions & 8 deletions Bohr/BOSetting.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@

@implementation BOSetting

+ (instancetype)settingWithKey:(NSString *)key {
return [[self alloc] initWithKey:key];
}

- (instancetype)initWithKey:(NSString *)key {
if (self = [super init]) {
_key = key;
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:self.key options:NSKeyValueObservingOptionNew context:nil];
if (key) {
if (self = [super init]) {
_key = key;
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:self.key options:NSKeyValueObservingOptionNew context:nil];
}
}

return self;
}

+ (instancetype)settingWithKey:(NSString *)key {
return [[self alloc] initWithKey:key];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
self.value = change[@"new"];
if (self.valueDidChangeBlock) self.valueDidChangeBlock();
Expand All @@ -38,8 +40,13 @@ - (void)setValue:(id)value {
}
}

- (void)setValueDidChangeBlock:(void (^)(void))valueDidChangeBlock {
_valueDidChangeBlock = valueDidChangeBlock;
if (valueDidChangeBlock) valueDidChangeBlock();
}

- (void)dealloc {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:self.key];
if (self.key) [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:self.key];
}

@end
6 changes: 3 additions & 3 deletions Bohr/BOSwitchTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
@interface BOSwitchTableViewCell : BOTableViewCell

/// The switch on the cell.
@property (nonatomic, strong) UISwitch *toggleSwitch;
@property (nonatomic) UISwitch *toggleSwitch;

/// The footer title when the toggle switch is on.
@property (nonatomic, strong) IBInspectable NSString *onFooterTitle;
@property (nonatomic) NSString *onFooterTitle;

/// The footer title when the toggle switch is off.
@property (nonatomic, strong) IBInspectable NSString *offFooterTitle;
@property (nonatomic) NSString *offFooterTitle;

@end
Loading

0 comments on commit a30fc70

Please sign in to comment.