LLVM / Clang error found in convenience method and NSClassFromString (...) alloc / release

I am analyzing an iPhone Objective-C project using the LLVM / Clang static analyzer. I keep getting two errors reported, but I'm sure the code is correct.

1) Convenience method.

+ (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] returns keepCount + 1. Am I correct?

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...

Are these some clan problems, or am I mistaken in both cases?

+3
source share
1 answer

. . 2, , , , performSelector initWithAdditive ( , ?). , . 1, , , [[[UILabel alloc] init...] autorelease] , .

+2

Source: https://habr.com/ru/post/1745786/


All Articles