From: Panayotis K. <pan...@pa...> - 2010-03-21 12:40:53
|
Hello again Today I experienced an issue, which produced some strange behavior and I am thinking if there is any way to solve it. This behavior actually appeared to me with UIWindow (which was easily solvable) but I am thinking of a more generic solution. The problem is with objects that request a specific initialization to be performed, other than [object init] The auto-generated code of any object has something like [[[NSObject alloc] init] autorelease] which is fine, but it is wrong with objects like UITableView which specifically request arguments in their initialization selector, which can not be changed afterwards (like the "style" property). What is done right now is to call once the generic "init" selector, and at later time call the more specific initWithFrame:style: selector. Thus initializing the object twice! In this specific case there doesn't seem to do any harm, but I have found out that in other cases, like UIWindow this might lead to serious problems! Of course solving UIWindow was an easy task, just replace initWithFrame: with setFrame: (since init was already called). I am wondering though: is there any way to call the specific initWithXXX: function instead of the generic one? Or, in other words, is it possible to avoid this double initialization of the object? PS: I am massively creating a patch to avoid if possible all non-needed init selectors in the library, but this is just a convenient solution for special cases, not a generic one. |