私はObjective-Cを初めて使用しますが、NSAutoreleasePoolを正しい方法で使用しているかどうかわかりません。
自動リリースを1回だけ使用したい場合は、次のようにします。
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *newText = [NSString stringWithFormat:@"%d", prograssAsInt]; sliderLabel.text = newText; [pool release]; //newText will be released
自動リリースを数回使用したい場合は、次を使用します。
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *newText = [NSString stringWithFormat:@"%d", prograssAsInt]; sliderLabel.text = newText; [pool drain]; //newText will be released newText = [NSString stringWithFormat:@"%d", prograssAsInt]; sliderLabel.text = newText; [pool drain]; //newText will be released newText = [NSString stringWithFormat:@"%d", prograssAsInt]; sliderLabel.text = newText; [pool release]; //newText will be released
これでいい?メモリリークはありますか?