【发布时间】:2012-01-05 05:25:01
【问题描述】:
我有此代码,需要将其移植到 arc,但我不知道如何:
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;
错误是:
error: 'class_createInstance' is unavailable: not available in automatic reference counting mode
如何替换?
我需要在运行时构建类对象。
【问题讨论】:
标签: xcode4 ios5 automatic-ref-counting