Created
February 4, 2011 00:07
-
-
Save robseward/810493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ImageNameManager.h | |
// | |
// Created by Rob Seward on 2/3/11. | |
// Copyright 2011 VHS DESIGN LLC. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface ImageNameManager : NSObject { | |
NSDictionary *mainMenuDict; | |
} | |
@property (nonatomic, readonly) NSDictionary* mainMenuDict; | |
+ (ImageNameManager*)sharedManager; | |
- (NSString *)appendHd:(NSString*)string; | |
- (void)appendHdToStrings:(NSMutableDictionary *)dict; | |
@end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ImageNameManager.m | |
// | |
// Created by Rob Seward on 2/3/11. | |
// Copyright 2011 VHS DESIGN LLC. All rights reserved. | |
// | |
#import "ImageNameManager.h" | |
#import "DeviceDetection.h" | |
static ImageNameManager *sharedManager = nil; | |
@implementation ImageNameManager | |
@synthesize mainMenuDict; | |
- (id)init { | |
if ( (self = [super init]) ) { | |
NSMutableDictionary *mainMenuTempDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: | |
@"mm_ground.png" , @"ground", | |
@"mm_seward_and_lee.png", @"logo", | |
@"read_story.png", @"readStory", | |
@"read_stroy_pressed.png", @"readStoryPressed", | |
@"read_to_me.png", @"readToMe", | |
@"read_to_me_pressed.png", @"readToMePressed", | |
@"auto_play.png", @"autoPlay", | |
@"auto_play_pressed.png", @"autoPlayPressed", | |
@"playground.png", @"playground", | |
@"playground_pressed.png", @"playgroundPressed", | |
@"mm_text.png", @"titleText", nil]; | |
//IF iPAD make all dictionaries HD or custom | |
if([DeviceDetection detectDevice] == MODEL_IPAD || [DeviceDetection detectDevice] == MODEL_IPAD_SIMULATOR){ | |
[self appendHdToStrings:mainMenuTempDict]; | |
} | |
mainMenuDict = [[NSDictionary alloc] initWithDictionary:mainMenuTempDict]; | |
return self; | |
} | |
- (void)appendHdToStrings:(NSMutableDictionary*)dict{ | |
NSArray *nameArray = [dict allKeys]; | |
for (int i=0; i < [nameArray count]; i++) { | |
NSString *key = [nameArray objectAtIndex:i]; | |
NSString *name = [dict objectForKey:key]; | |
name = [self appendHd:name]; | |
[dict removeObjectForKey:key]; | |
[dict setObject:name forKey:key]; | |
} | |
} | |
- (NSString *)appendHd:(NSString*)string{ | |
NSString *suffix = @".png"; | |
NSRange range = [string rangeOfString:suffix]; | |
NSString *prefix = [string substringToIndex:range.location]; | |
NSString *appendedString = [NSString stringWithFormat:@"%@-hd%@", prefix, suffix]; | |
return appendedString; | |
} | |
- (void)dealloc { | |
// Should never be called, but just here for clarity really. | |
[mainMenuDict release]; | |
[super dealloc]; | |
} | |
#pragma mark Singleton Methods | |
+ (id)sharedManager { | |
@synchronized(self) { | |
if(sharedManager == nil) | |
sharedManager = [[super allocWithZone:NULL] init]; | |
} | |
return sharedManager; | |
} | |
+ (id)allocWithZone:(NSZone *)zone { | |
return [[self sharedManager] retain]; | |
} | |
- (id)copyWithZone:(NSZone *)zone { | |
return self; | |
} | |
- (id)retain { | |
return self; | |
} | |
- (unsigned)retainCount { | |
return UINT_MAX; //denotes an object that cannot be released | |
} | |
- (void)release { | |
// never release | |
} | |
- (id)autorelease { | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment