您的位置:首页 > 移动开发 > Objective-C

Initializing 'Object' *__strong' with an expression of incompatible type 'id <Object> _Nullable

2017-05-15 16:17 483 查看
问题:

出现Initializing ‘Object’ *__strong’ with an expression of incompatible type ‘id _Nullable 的警告

解决办法:

例1:

使用ARC时,获取全局的AppDelegate会有上面的警告。

修改前:

AppDelegate *app = [UIApplication sharedApplication].delegate;


修改后:即(强制转换)

AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate;


例2:

修改前:

NIMNotificationObject *object = lastMessage.messageObject;


修改后:即(强制转换)

NIMNotificationObject *object = (NIMNotificationObject *)lastMessage.messageObject;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐