これは、Xcode 4 静的アナライザーに関する以前の質問へのフォロー アップです。コードが必要に応じて機能するようになったので、特に問題はありませんが、舞台裏でどのように機能しているのか疑問に思っています。次のコードを検討してください。
- (IBAction)cameraButtonPressed:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
{
return;
}
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
[self presentModalViewController:cameraUI animated:YES];
NSString *theString = [[NSString alloc] initWithString:@"cameraButtonPressed done"];
NSLog(@"%@", theString);
}
私には、このコードの見た目から、リリースする必要がある 2 つのオブジェクト (cameraUI と theString) があります。ただし、analyze 関数は、両方のオブジェクトが alloc-init から返されたとしても、メソッドの最後で解放する必要があるのは theString のみであることを正しく識別します。
ここでの質問は、静的コード アナライザーが cameraUI を問題としてフラグ付けしないことをどのように認識しているのかということです。