"Andrés G. Aragoneses" píše v Čt 21. 01. 2010 v 02:57 +0100:
Hi there, My question is simple: can the "weak" keyword be used for local variables instead of fields? (Sorry I cannot check it right now with the last version.) If yes (or if it will in some future version), does it really have any sense? Can I see an example? Thanks, Andrés
Hi Andrés, in case I didn't oversleep, 'weak' keyword still doesn't have it's intended semantics. You shouldn't use it (yet), because it's meaning will change in the future. 'unowned' should be used instead (at the moment the two are the same). But to your question: you can use it for both fields and local variables. In the future, 'unowned' will stay as it is now, but 'weak' will keep track of the object you are referencing with it, setting itself to null when it's destroyed. Whether it makes sense for local variables depends on what you're trying to achieve. Mostly it's irrelevant for the programs function, but 'unowned' can be used as a mean of performance optimization (only use when you really know what you're doing).
Attachment:
signature.asc
Description: Toto je digitálně podepsaná část zprávy