Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dayitv89/configuration-manager
Configuration Manager for Framework
https://github.com/dayitv89/configuration-manager
Last synced: 9 days ago
JSON representation
Configuration Manager for Framework
- Host: GitHub
- URL: https://github.com/dayitv89/configuration-manager
- Owner: dayitv89
- Created: 2016-01-18T11:31:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-21T13:21:55.000Z (about 9 years ago)
- Last Synced: 2023-03-24T08:42:22.639Z (almost 2 years ago)
- Language: Objective-C
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Configuration Manager
Rules for making new Configuration class
- Must inherit from `BaseConfig`
- Must implement the protocol `BaseConfigProtocol`
- Must write `CREATE_SHARED_INSTANCE` after the @implement ClassName (Override the `+sharedInstance` method by the macro defined in `BaseConfig`)****
- Must set properties value by iVAR name instead of setter in `setDefaultConfigurationFrom:` method. (Because in runtime class all setter override to do nothing method)use **_appName** instead of ~~self.appName~~
```Objective-c
- (void)setDefaultConfigurationFrom:(id)obj {
AppConfig *appConfig = (AppConfig*)obj;
✓ _appName = appConfig.appName?:@"AppConfig App";
✗ self.appName = appConfig.appName?:@"AppConfig App";
}
```
****
### Sample code for `AppConfig`
`AppConfig.h`
```Objective-c
#import "BaseConfig.h"@interface AppConfig : BaseConfig
@property (nonatomic, strong) NSString *appName;
@property (nonatomic, strong) NSString *appVersion;
@property (nonatomic) NSInteger appUserMiniumAge;@end
@protocol AppConfigProtocol
- (void)customAppConfig:(AppConfig*)appConfig;
@end
````AppConfig.m`
```Objective-c
#import "AppConfig.h"@implementation AppConfig
CREATE_SHARED_INSTANCE
- (void)setDefaultConfigurationFrom:(id)obj {
AppConfig *appConfig = (AppConfig*)obj;
_appName = appConfig.appName?:@"AppConfig App";
_appVersion = appConfig.appVersion?:@"1.0.1";
_appUserMiniumAge = appConfig.appUserMiniumAge?:15;
}- (void)callDataSourceForCustom:(id)objCustom {
if (objCustom && [objCustom conformsToProtocol:@protocol(AppConfigProtocol)]) {
[objCustom customAppConfig:self];
}
}@end
```