[英]Comparing in objective C - Implicit conversion of 'int' to 'id' is disallowed with ARC
[英]Obj-C Error "Implicit Conversion of Int to Collection * is disallowed with ARC
- (void)saveCollectionMoment:(NSArray *)collectionMoments
{
for (NSDictionary *momentData in collectionMoments) {
int mID = [[momentData objectForKey:@"mID"] intValue];
FMDBDataAccess *db = [[FMDBDataAccess alloc] init];
[db insertMoment:mID toCollection: cID];
}
}
以上应该采用从JSON返回提供的id并使用FMDB更新SQLite数据库表与mID和cID所有我得到的是以下错误。
ARC不允许将'int'隐式转换为'Moment *'
我们将非常感谢您的帮助。
问题是insertMoment:toCollection:
期望一个Moment*
对象作为它的第一个参数,而你试图传递一个整数ID。
您应该将代码更改为let insertMoment:toCollection:
接受整数MomentID
作为其第一个参数,或者在调用insertMoment:toCollection:
方法之前通过其MomentID
获取Moment*
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.