为什么要将nil分配给nsmutabledictioanry并且分配是在这个位置崩溃和显示内存释放?
self.delegate.replenishAddedmaterials = nil;
self.delegate.replenishAddedmaterials = [[NSMutableDictionary alloc] init];
MATERIAL_ITEM *materialItem = [[MATERIAL_ITEM alloc] init];
VENDOR_HEADER *vendor = [[VENDOR_HEADER alloc] init];
PURCHASING_ORG_HEADER *purOrg = [[PURCHASING_ORG_HEADER alloc] init];
[self.delegate.replenishAddedmaterials setObject:[NSMutableArray arrayWithObject:materialItem] forKey:materialItem];
[[self.delegate.replenishAddedmaterials objectForKey:materialItem] addObject:vendor];
[[self.delegate.replenishAddedmaterials objectForKey:materialItem] addObject:purOrg];
执行nsmutabledictionary的分配后,我收到以下消息
* - [MATERIAL_ITEM release]:发送到解除分配的实例0x11e62810的消息>我已经在ARC中实现了我的项目
答案 0 :(得分:1)
你确定这条线是正确的吗?
[self.delegate.replenishAddedmaterials setObject:[NSMutableArray
arrayWithObject:materialItem] forKey:materialItem];
您正在使用数组上的对象作为键,这真的很奇怪。
尝试自己创建一个密钥:
[self.delegate.replenishAddedmaterials setObject:[NSMutableArray
arrayWithObject:materialItem] forKey:@"materialItemKey"];