The theme JSON is converted into NSDictionary, NSArray, and other NSObject instances by the Apple JSON parser. The theme code pulls the styles from these objects either on demand (for style IDs) or when the app starts (for Appearance Proxy compatible styles). The styles are applied in the same way no matter what type of style is used: an instance of the target object is obtained, the selector name is read from the parsed JSON, then looked up on the target object. Next, the selector's parameter values are read from the parsed JSON and a method is called that knows how to convert each value string into the object it describes, based on the @type value. Once these parameters are created, the selector is called on the target object and the parameter values are passed.

Calling selectors like this is slower than calling selectors directly, but it is fast enough not to appreciably degrade performance. It is, however, worth bearing in mind that there is extra work happening than there would be if the styling information were coded directly in Objective-C. It is worth trying to be economical with style properties: if a View will have multiple styles applied to it, avoid duplicating style properties in each style, as it would result in wasted calls. In practice it is unlikely any realistic number of styles or style properties would affect performance, but it's generally better to be fastidious.


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices