如何在弧中替换class_createInstance?

use*_*923 6 xcode4 ios5 automatic-ref-counting

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

        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)

怎么更换它?

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

Jas*_*ues 1

尝试这个:

#include <objc/objc-runtime.h>
id object = [[NSClassFromString(@"TheClassName") alloc] init];
Run Code Online (Sandbox Code Playgroud)