On Sep 21, 2010, at 15:37, Sean McBride wrote: > If I have a plain C struct that contains some Obj-C object pointers like: > > struct { > int boring; > NSString* string; > } MyStruct > > What must I do to be safe in GC? > > a) I know I must allocate my structs using NSAllocateCollectable and > NSScannedOption. > b) I'm pretty sure I don't need a '__strong' in my struct declaration. > (doc say "__strong is implicitly part of any declaration of an Objective- > C object reference type.") > c) I'm pretty sure if I use a pointer to this struct as an ivar, I must > tag it with __strong.
At risk of getting myself into trouble, I'd say correct, correct and correct. > d) I'm not sure about passing pointers to this struct around. Need I > tag all parameters and return values as __strong too? ex: > > void DoThing (__strong MyStruct* param) { ... } At ditto risk, I'd say no to '__strong'. Variable 'param' is a stack variable is therefore a *root* reference, and as such the concept of strong or weak doesn't apply. (That is, AFAIK, applying '__strong' or '__weak' to a stack variable *never* has any effect on its behavior in any way.)_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com