marcoarment / FCModel

An alternative to Core Data for people who like having direct SQL access.
MIT License
1.65k stars 173 forks source link

Don't crash when using custom tableName #55

Closed marcboquet closed 10 years ago

marcboquet commented 10 years ago

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.

marcoarment commented 10 years ago

Moving discussion into #57. I'll reopen this if support for +tableName remains.