繁体   English   中英

Obj-C错误“ARC不允许将Int隐式转换为集合*

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM