Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexdenisov/ios_generate_settings
Generate settings manager Objective-C class from command ine
https://github.com/alexdenisov/ios_generate_settings
Last synced: about 1 month ago
JSON representation
Generate settings manager Objective-C class from command ine
- Host: GitHub
- URL: https://github.com/alexdenisov/ios_generate_settings
- Owner: AlexDenisov
- Created: 2012-04-02T13:55:46.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-04-03T04:47:18.000Z (over 12 years ago)
- Last Synced: 2024-10-05T21:46:16.115Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 91.8 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= iOS SettingsManager generator
=== Simple gem which generate SettingsManager singleton= Installation
gem install ios_generate_settings
= Usage
ios_generate_settings login:NSString password:NSString count:NSNumber=== When you restart script the new properties will be added
= Generated sources
// SettingsManager.h
#import//string_constants
static NSString *const kName = @"name";
static NSString *const kCount = @"count";@interface SettingsManager : NSObject
//property_declaration
@property (nonatomic, retain, readwrite) NSString *name;
@property (nonatomic, retain, readwrite) NSNumber *count;+ (id)sharedInstance;
- (void)saveValue:(id)aValue forKey:(NSString*)aKey;
@end// SettingsManager.m
@implementation SettingsManager
//property_implementation
@synthesize name;
@synthesize count;static SettingsManager *settingsManagerInstance = nil;
- (id)init
{
self = [super init];
if (self) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//load_properties
self.name = [defaults valueForKey:kName];
self.count = [defaults valueForKey:kCount];}
return self;
}- (void)dealloc {
//release_properties
self.name = nil;
self.count = nil;[super dealloc];
}- (void)saveValue:(id)aValue forKey:(NSString *)aKey {
[[NSUserDefaults standardUserDefaults] setValue:aValue forKey:aKey];
[[NSUserDefaults standardUserDefaults] synchronize];
[self setValue:aValue forKey:aKey];
}+ (id)sharedInstance {
if(nil == settingsManagerInstance){
settingsManagerInstance = [[SettingsManager alloc] init];
}
return settingsManagerInstance;
}@end