Мое приложение говорит мне, что я чрезмерно отпуская NSDecimalNumber tempDouble ниже:Чрезмерная выпустив NSDecimalNumber
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setLocale:[NSLocale currentLocale]];
[currencyFormatter setGeneratesDecimalNumbers:TRUE];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
// Here is the key: use the maximum fractional digits of the currency as the scale
int currencyScale = [currencyFormatter maximumFractionDigits];
NSDecimalNumber* tempDouble = [[NSDecimalNumber alloc] initWithString:self.tempStore];
NSDecimalNumber* numTen = [[NSDecimalNumber alloc] initWithInt:10];
tempDouble = [tempDouble decimalNumberByDividingBy:[numTen decimalNumberByRaisingToPower:currencyScale]];
[numTen release];
[textField setText:[currencyFormatter stringFromNumber:tempDouble]];
[currencyFormatter release];
[tempDouble release];
Я думаю, что проблема заключается в следующем один:
tempDouble = [tempDouble decimalNumberByDividingBy:[numTen decimalNumberByRaisingToPower:currencyScale]];
Но я не уверен, почему. Должен ли я добавлять атрибут «присваивать, копировать или сохранять» после назначения? Когда я избавлюсь от инструкции «release» ниже, код работает нормально.
Спасибо,
G
На каком языке это? Скажите, пожалуйста, чтобы я мог игнорировать его тег. – 2010-11-26 21:37:17