icanzilb/JSONModel — pull request #6 by mhupman (2012-12-21 01:43:27+00:00)
Title: Change +load to +initialize

Using +load seems to cause an issue where the static, class level variables in JSONModel.m (like "allowedJSONTypes") are dealloc'ed before use. Interestingly, this only seems to happen when you are linking to a compiled library that contains JSONModel instead of pulling the JSONModel source directly into your project. The reasons for doing so could be numerous, but in my use case I'm trying to create a CocoaPod for JSONModel to facilitate easy integration.

I tested the change from +load to +initialize in both my app (using CocoaPods) and the JSONModel Demo project, and both seem unaffected. It seems to me that +initialize in general is a better place for this kind of setup code. See the links below for some of the differences between the two. The biggest difference, in my mind, is that +load is called _outside_ of a autoreleasepool. I know that +initialize can be called more than once under certain situations, but since its wrapped in a dispatch_once call anyway that isn't a concern.

http://blog.federicomestrone.com/2011/05/16/objective-c-load-and-initialize/
http://www.friday.com/bbum/2009/09/06/iniailize-can-be-executed-multiple-times-load-not-so-much/