I have this following code :
NSAssert(dst, @"sdiasiosadiodasio");
// Add to a list so that we don't lose the references
[layersToDsts setObject:dst forKey:layer];
NSLog(@"The key is %lu", layer);
for (Bit *layer in [layersToDsts allKeys])
{
BitHolder *dst = [layersToDsts objectForKey:layer];
NSLog(@"My added key is %lu", layer);
NSAssert(dst, @"ddddd");
}
layersToDsts is a mutable NSDictionary. I’m trying to use the address of an object as the key, mapping to another object.
The code worked on iOS 5. For some reason, the code gives
The key is 484196128
My added key is 484253328
Assertion failure in -[Animator animateImpl:] 'NSInternalInconsistencyException', reason: 'ddddd'
Obviously, the object I added to the dictionary can’t be retrieved. The object isn’t nil. Why the mapping key is another address?? The code worked perfectly on iOS 5….
CALayer does not implement the NSCopying protocol and so can not be used as a key, use the address of the CALayer and turn it into an NSNumber you ay alternatively be able to use the name property on CALayer.