【问题标题】:assign value from server to integer in objective -c在目标-c中将值从服务器分配给整数
【发布时间】:2017-06-27 08:12:02
【问题描述】:

我来自 swift 背景,我在 Objective-c 中有一个代码,它从服务器获取值,它正确地获取了下面的代码。

if (![message_expiration intValue]){
    NSLog(@"Check the message expiration integer value");


    _MessageExpire = [message_expiration intValue];




}

我有一个变量:

@property (nonatomic, assign) NSInteger *MessageExpire;

我想要的是:我的整数变量取来自服务器的值,我是这样做的:

_MessageExpire = [message_expiration intValue];

但我得到的错误是:不兼容的整数到指针转换分配.....

任何帮助表示感谢

【问题讨论】:

  • NSInteger 之后删除*。这不是指针。
  • 顺便说一句:请尊重 Objective-C 命名约定。
  • 谢谢@Sulthan,它可以工作,谢谢大家:)

标签: objective-c int nsuinteger


【解决方案1】:

目标 - C

没有将指针(*)分配给NSInteger

@property (nonatomic, assign) NSInteger MessageExpire;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-21
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2014-12-14
    相关资源
    最近更新 更多