【发布时间】:2011-06-07 19:44:50
【问题描述】:
注意下面注释掉的[printvolfirst release]; 行。如果我取消注释,程序就会崩溃。我不知道为什么。 printvolfirst 变量不会在其他任何地方使用,除了您在此处看到的代码行。将其分配给printvol 后,我就完成了。那么为什么不发布呢?
vol = vol / 1000000;
NSNumberFormatter * format = [[NSNumberFormatter alloc] init] ;
[format setPositiveFormat:@"#.#"];
NSString * printvolfirst = [[NSString alloc]init];
printvolfirst = [format stringFromNumber:[NSNumber numberWithFloat:vol]];
NSString * printvol = [[NSString alloc] initWithFormat: @"%@M", printvolfirst];
self.Pop.vol.text = printvol;
[printvol release];
//[printvolfirst release];
[format release];
【问题讨论】:
标签: objective-c cocoa memory-management nsstring