Search code examples
objective-cios5intautomatic-ref-countingfmdb

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];
    }
}

the above is supposed to take an id provided from a JSON return and using FMDB update the SQLite database table with the mID and cID all i get though is the following errors.

Implicit conversion of 'int' to 'Moment *' is disallowed with ARC

ANy help will be gratefully received.


Solution

  • The problem is that the insertMoment:toCollection: expects a Moment* object as its first argument, while you are trying to pass it an integer ID instead.

    You should change your code to either let insertMoment:toCollection: accept an integer MomentID as its first argument, or by fetching a Moment* by its MomentID before calling the insertMoment:toCollection: method.