I have this code and need to port it to arc but I dont know how:
case FIELDTYPE_OBJECT:
className = [fieldType substringWithRange:NSMakeRange(2, [fieldType length]-3)];
rel = class_createInstance(NSClassFromString(className), sizeof(unsigned));
Class theClass = [rel class];
if ([rel isKindOfClass:[DbObject class]]) {
//Load the record...
NSInteger Id = [rs intForColumn:[theClass relationName]];
if (Id==0) {
fieldValue = [rel init];
} else {
Db *db = [Db currentDb];
fieldValue = [db loadById: theClass theId:Id];
}
}
break;
The error is:
error: 'class_createInstance' is unavailable: not available in automatic reference counting mode
How replace it?
I need to build class objects in runtime.
The most straightforward solution is to add another file which has -fno-objc-arc set on it, and which has a function which calls class_createInstance() as above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With