Мое приложение сообщает, что я переиздаю NSDecimalNumber tempDouble ниже:
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