Last Updated: February 25, 2016
·
1.223K
· e0d

Convert SQLite to CoreData

NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
        NSString* path = [NSString stringWithFormat:@"%@/CoreDataSourceFile.sqlite", bundlePath];
        SQLiteDatabase *database = [[SQLiteDatabase alloc] initWithPath:path];
        NSArray *result = [database performQuery:@"SELECT * FROM entity"];
        for (NSArray *row in result)
        {entityText
            NSString *entityText = [row objectAtIndex:1];
            const char *macString = [entityText cStringUsingEncoding:NSMacOSRomanStringEncoding];
            NSString *cstr =  [[NSString alloc]initWithCString:macString encoding:NSUTF8StringEncoding];

 [CoreData addToCoreData:cstr];
        }