小编use*_*923的帖子

如何在弧中替换class_createInstance?

我有这个代码,需要将它移植到弧,但我不知道如何:

        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;
Run Code Online (Sandbox Code Playgroud)

错误是:

error: 'class_createInstance' is unavailable: not available in automatic reference counting mode
Run Code Online (Sandbox Code Playgroud)

怎么更换它?

我需要在运行时构建类对象.

xcode4 ios5 automatic-ref-counting

6
推荐指数
1
解决办法
1245
查看次数

标签 统计

automatic-ref-counting ×1

ios5 ×1

xcode4 ×1