20. August 2014 11:38
I can't take the credit for finding this, that belongs to @booranger
, but he's fierce blog-shy so I'll post it 😃
While updating some existing apps to ensure they run all lovely on iOS 8 we happened across a nice infinite recursion issue in some of our internal library code.
dictionary, description, dictionary, description, dictionary, description, dictionary, description, dictionary, description, dictionary, description, dictionary, description, dictionary, description, ASPLODE, KABOOM, CRASH!!!!
Bit of background…
is a parent class that most
of our model classes inherit from. It has some convenient stuff on it like being able to create and save itself to and from NSDictionary/JSON/SQLite and so on. One of the tricks it uses is Objective-C's runtime ability to inspect classes with class_copyPropertyList
. In a nutshell, we recursively traverse the property tree of an object until we reach the top. Encounter something easy like a string, number, etc and we just store it a key/value pair. Encounter something more complex like another RWSSerializationObject and we perform the same trick on it. Result is we end up with the complete model in an NSDictionary.
Logging out the properties on our object produced different results on iOS 7 and iOS 8.
Straight away we can see that there are more properties on iOS 8 for some reason. But what are they…
But those aren't properties you scream, we all scream… They are methods… everyone knows that. So why are they appearing as properties all of a sudden.
The big reveal
In iOS 8 they've been promoted/demoted to methods…
If you are using class_copyPropertyList
you may want to check that your app doesn't blow up on iOS 8 because of these "new" properties.