NSDecimalNumber to String在UILabel上不打印任何内容

时间:2014-12-02 21:05:06

标签: ios objective-c ios7 nsdecimalnumber

我的模特有

@property (nonatomic, strong) NSDecimalNumber *totalSpent;

当我记录

 NSLog(@"totalSpent:%@", self.monthlySummaryModel.totalSpent);

我得到了

2014-12-02 12:59:47.287 app-ios[16741:60b] totalSpent:2037.01 

现在我想在UILabel

上添加此内容
@property(nonatomic, weak) IBOutlet UILabel *totalSpentLabel;

我将值指定为

self.totalSpentLabel.text = [self.monthlySummaryModel.totalSpent stringValue];

但我在页面上看到的并不是什么 enter image description here

这可能是什么问题?

1 个答案:

答案 0 :(得分:0)

问题是数据是从API获取的,我必须在获取数据后更新标签

self.monthlySummaryModel = [[MonthlySummaryModel alloc] initWithJson:monthlySummary];
            NSLog(@"totalSpent:%@", self.monthlySummaryModel.totalSpent);

            [self.tableView reloadData];
            [self setSummarySpentView];

- (void)setSummarySpentView {
    self.SummarySpentView.backgroundColor = [UIColor colorWithRed:44 / 255.0f green:62 / 255.0f blue:80 / 255.0f alpha:1.0f];
    self.totalSpentLabel.text = [self.monthlySummaryModel.totalSpent stringValue];
}