我有一个NSDictionary类别中的以下方法,做一个深层复制,这工作正常。 我刚从Xcode 4.1升级到4.2,Analyze函数给出了这个代码的两个分析器警告,如下所示: – (id)deepCopy; { id dict = [[NSMutableDictionary alloc] init]; id copy; for (id key in self) { id object = [self objectForKey:key]; if ([object respondsToSelector:@selector(deepCopy)]) copy = [object deepCopy]; else copy = [object copy]; [dict setObject:copy forKey:key]; // Both -deepCopy and -copy retain the object, and so does -setObject:forKey:, so need to […]