LLVM/Clang静的アナライザーを使用してObjective-CiPhoneプロジェクトを分析しています。報告されたバグは2つありますが、コードは正しいと確信しています。
1)便利な方法。
+ (UILabel *)simpleLabel
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 200, 25)];
label.adjustsFontSizeToFitWidth = YES;
[label autorelease]; // Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected.
return label;
}
2)[NSClassFromString(...)alloc]はretainCount + 1を返します。私は正しいですか?
Class detailsViewControllerClass =
NSClassFromString(self.detailsViewControllerName);
UIViewController *detailsViewController =
[[detailsViewControllerClass alloc]
performSelector:@selector(initWithAdditive:) withObject:additive];
[self.parentController.navigationController
pushViewController:detailsViewController animated:YES];
[detailsViewController release]; // Incorrect decrement of the reference count of an object is not owned...
これらはいくつかのClangの問題ですか、それとも私はこれらの両方のケースで完全に間違っていますか?