marcoarment / FCModel

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

Fixes a crash due to missing unique map init when creating new instances #38

Closed felixLam closed 10 years ago

felixLam commented 10 years ago

Previously the following line would crash if this was the first interaction with the model, because g_instancesReadLock was not initialized.

dispatch_semaphore_wait(g_instancesReadLock, DISPATCH_TIME_FOREVER);

The following lines would also not work without this change:

if (! classCache) classCache = g_instances[(id) self.class] = [NSMapTable strongToWeakObjectsMapTable];
marcoarment commented 10 years ago

Thanks!

felixLam commented 10 years ago

One more thought: currently this method gets called in three locations, would it maybe make sense to call it once in openDatabaseAtPath instead?