Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

删除app后重新安装,出现bug #18

Open
xuzixian opened this issue Jan 8, 2016 · 1 comment
Open

删除app后重新安装,出现bug #18

xuzixian opened this issue Jan 8, 2016 · 1 comment

Comments

@xuzixian
Copy link

xuzixian commented Jan 8, 2016

删除app后重新安装,会一直提示以下问题,请问怎么解决,谢谢!
注意:你操作的模型SYPersonModel在数据库中没有对应的数据表,框架正在全自动创表,并稍后自动重新执行您的操作,请放心!

@xuzixian
Copy link
Author

xuzixian commented Jan 9, 2016

问题已解决,出现这个问题的原因是,我临时更改数据库路径,然后,在调用时没有对CoreModel的所有子类建表,解决的办法就是对CoreModel重新建表
#include <objc/runtime.h>

  • (NSArray *)findAllOf:(Class)defaultClass{

    int count = objc_getClassList(NULL, 0);
    if (count <= 0){

    @throw@"Couldn't retrieve Obj-C class-list";
    return [NSArray arrayWithObject:defaultClass];
    

    }

    NSMutableArray *output = [NSMutableArray arrayWithObject:defaultClass];

    Class *classes = (Class *) malloc(sizeof(Class) * count);

    objc_getClassList(classes, count);

    for (int i = 0; i < count; ++i) {
    if (defaultClass == class_getSuperclass(classes[i])){//子类

        [output addObjectsFromArray:[CoreModel findAllOf:classes[i]]];
    }
    

    }

    free(classes);

    return [NSArray arrayWithArray:output];
    }

下面是重新建表
NSArray *array = [CoreModel findAllOf:[CoreModel class]];
for (id classStr in array) {
[classStr initialize];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant