Skip to content

Instantly share code, notes, and snippets.

@tangqiaoboy
Created December 25, 2011 12:19
Show Gist options
  • Save tangqiaoboy/1519172 to your computer and use it in GitHub Desktop.
Save tangqiaoboy/1519172 to your computer and use it in GitHub Desktop.
objective c test code
+ (ImageCache *) sharedInstance {
if (instance == nil) {
@synchronized(self) {
if (instance == nil) {
instance = [[ImageCache alloc] init];
}
}
}
return instance;
}
- (id) init {
if (self = [super init]) {
self.cachePath = NSTemporaryDirectory();
self.fileManager = [NSFileManager defaultManager];
self.memoryCache = [[NSMutableDictionary alloc] initWithCapacity:MAX_MEMORY_CACHE_NUMBER];
self.memoryCacheKeys = [[NSMutableArray alloc] initWithCapacity:MAX_MEMORY_CACHE_NUMBER];
return self;
}
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment