【问题标题】:How can I retrieve a textfields text and store it as an integer 32 in core data?如何检索文本字段文本并将其作为整数 32 存储在核心数据中?
【发布时间】:2012-05-03 00:22:49
【问题描述】:

我正在尝试获取文本字段文本,将其转换为 int,并将其存储在核心数据整数 32 属性中。我在处理过程中遇到错误:

Implicit conversion of 'int' to 'NSNumber' disallowed  with arc

这是我尝试过的:

// trying to convert
int intLength = [self.length.text intValue];

// trying to set the current garden attribute to the converted int
self.currentGarden.length = intLength;

我该如何解决这个问题?

【问题讨论】:

    标签: objective-c ios core-data ios5


    【解决方案1】:

    NSNumber 是一个对象,与 int 不同。尝试使用构造函数创建一个 NSNumber:

    self.currentGarden.length = [NSNumber numberWithInt:intLength];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-12
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多