Permalink
Browse files

Switch over to NSMapTable internally since it seems likely Apple will…

… close the CFDictionarySetValue loophole.
  • Loading branch information...
1 parent d330ab4 commit 5042cac3e6a2cb2369c1e4bb4eadba0d1d82d1cf @mikeabdullah mikeabdullah committed Apr 22, 2012
Showing with 5 additions and 8 deletions.
  1. +1 −1 IMBObjectsPromise.h
  2. +4 −7 IMBObjectsPromise.m
View
@@ -83,7 +83,7 @@ extern NSString* kIMBPasteboardTypeObjectsPromise;
{
@private
NSArray* _objects;
- NSMutableDictionary* _URLsByObject;
+ NSMapTable *_URLsByObject;
@protected
NSString* _destinationDirectoryPath;
NSError* _error;
View
@@ -132,7 +132,7 @@ - (id) initWithIMBObjects:(NSArray*)inObjects
if (self = [super init])
{
self.objects = inObjects;
- _URLsByObject = [[NSMutableDictionary alloc] initWithCapacity:inObjects.count];
+ _URLsByObject = [[NSMapTable mapTableWithStrongToStrongObjects] retain];
self.destinationDirectoryPath = [IMBConfig downloadFolderPath];
self.error = nil;
self.delegate = nil;
@@ -152,7 +152,7 @@ - (id) initWithCoder:(NSCoder*)inCoder
if (self = [super init])
{
self.objects = [inCoder decodeObjectForKey:@"objects"];
- _URLsByObject = [[inCoder decodeObjectForKey:@"URLsByObject"] mutableCopy];
+ _URLsByObject = [[inCoder decodeObjectForKey:@"URLsByObject"] retain];
self.destinationDirectoryPath = [inCoder decodeObjectForKey:@"destinationDirectoryPath"];
self.delegate = nil;
self.finishSelector = NULL;
@@ -179,7 +179,7 @@ - (id) copyWithZone:(NSZone*)inZone
IMBObjectsPromise* copy = [[[self class] allocWithZone:inZone] init];
copy.objects = self.objects;
- copy->_URLsByObject = [_URLsByObject mutableCopy];
+ copy->_URLsByObject = [_URLsByObject copy];
copy.destinationDirectoryPath = self.destinationDirectoryPath;
copy.error = self.error;
copy.delegate = self.delegate;
@@ -391,12 +391,9 @@ - (void) recoveryAttempter
- (void)setFileURL:(NSURL *)URL error:(NSError *)error forObject:(IMBObject *)object;
{
- // Drop down to CF to avoid copying keys
if (URL)
{
- CFDictionarySetValue((CFMutableDictionaryRef)_URLsByObject,
- object,
- (URL ? (id)URL : (id)error));
+ [_URLsByObject setObject:(URL ? (id)URL : (id)error) forKey:object];
// Post process. We use this to embed metadata after the download. This is only really used by Flickr images right now

0 comments on commit 5042cac

Please sign in to comment.