【问题标题】:Assigning to 'readonly' return result of an Objective-C message not allowed [duplicate]不允许分配给 Objective-C 消息的“只读”返回结果 [重复]
【发布时间】:2013-12-11 21:12:50
【问题描述】:

在这行代码上:

[self.a8.text intValue]=[self.a7.text intValue]+[self.a6.text intValue];

我收到此编译器错误:

不允许分配给 Objective-C 消息的“只读”返回结果

为什么会发生这种情况,我该如何解决?

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    你不能赋值给 intValue 的返回值。试试

    self.a8.text = [NSString stringWithFormat:@"%d", [self.a7.text intValue]+[self.a6.text intValue]];
    

    假设 self.a8.text 是可赋值的

    【讨论】:

      猜你喜欢
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-28
      • 2013-04-29
      相关资源
      最近更新 更多