There are any number of ways to accomplish this. Here is my idea.
Create an NSObject called Style. It will hold all the information you need changed. So if for example you need a different title for each of four view controllers, a different background color for each, and a different image in two of them, it could look like this:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface Style : NSObject
@property (nonatomic, retain) NSString* first_title;
@property (nonatomic, retain) NSString* second_title;
@property (nonatomic, retain) NSString* third_title;
@property (nonatomic, retain) NSString* fourth_title;
@property (nonatomic) UIColor* first_background_color;
@property (nonatomic) UIColor* second_background_color;
@property (nonatomic) UIColor* third_background_color;
@property (nonatomic) UIColor* fourth_background_color;
@property (nonatomic) UIImage* first_image;
@property (nonatomic) UIImage* second_image;
@end
Then, in your Style.m, you could have methods to save this information to memory, like this:
// encode a card to memory
- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:first_title forKey:@"first_title"];
// etc etc etc
}
// decode a card from memory
- (id)initWithCoder:(NSCoder *)coder {
self = [self init];
self.first_title = [coder decodeObjectForKey:@"first_title"];
// etc etc etc
return self;
}
Next, you could (in your app delegate or basically wherever you want) create an NSArray* of Styles - one for each of the companies involved. I could think of any number of places to do this - you could do it in the app delegate in didFinishLaunchingWithOptions
, or you could even store some TSV files on a server, fetch them in the viewDidLoad and parse them into this array. Whatever you want! Anyway, once you have some awesome array of Styles - one for each company - you can fetch and save it to and from app memory like this:
-(void)writeArrayWithCustomObjToUserDefaults:(NSString*)keyName withArray:(NSMutableArray*)myArray {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:myArray];
[defaults setObject:data forKey:keyName];
[defaults synchronize];
}
And to get the array back from memory:
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"Styles"] != nil) {
NSData* existingData = [[NSUserDefaults standardUserDefaults] objectForKey:@"knives"];
NSArray* styles = [NSKeyedUnarchiver unarchiveObjectWithData:existingData];
}
Then, in your various VC's, just fetch the NSArray of Styles, find the one with a name corresponding to your target, and access its variables to modify the VC!
More information on getting target name here.
More information on that memory stuff here.