我有以下代码:
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 是一个可变的NSDictionary
。我正在尝试使用对象的地址作为键,映射到另一个对象。
该代码适用于 iOS 5。出于某种原因,该代码给出了
The key is 484196128
My added key is 484253328
Assertion failure in -[Animator animateImpl:] 'NSInternalInconsistencyException', reason: 'ddddd'
显然,我添加到字典中的对象无法检索。对象不是零。为什么映射键是另一个地址?该代码在 iOS 5 上完美运行......