When a model uses a custom tableName its info doesn't get added to g_fieldInfo and g_primaryKeyFieldName when opening the database, this causes a crash when using the model later.
Here I'm using objc_getClassList to find all the subclasses of FCModel and ask for the tableName if NSClassFromString(tableName) returns nil, maybe it's too hacky?
If you'd prefer a cleaner solution then a registerClass: approach would be it I guess, but then you'd be requiring subclasses to register. Matt Gallagher has this post from where I took the ClassGetSubclasses() code and he outlines it.
When a model uses a custom
tableName
its info doesn't get added tog_fieldInfo
andg_primaryKeyFieldName
when opening the database, this causes a crash when using the model later. Here I'm usingobjc_getClassList
to find all the subclasses of FCModel and ask for thetableName
ifNSClassFromString(tableName)
returns nil, maybe it's too hacky? If you'd prefer a cleaner solution then aregisterClass:
approach would be it I guess, but then you'd be requiring subclasses to register. Matt Gallagher has this post from where I took theClassGetSubclasses()
code and he outlines it.