Re: C struct and __unsafe_unretained

2011-10-30 Thread Thomas Davie
Yes and no – it means you have an NSString there that can disappear at any moment without warning, and when it does, you'll still have a pointer into garbage memory. Also, if the original code has been copying/retaining it into the struct and releasing it out, then it's entirely possible that b

Re: C struct and __unsafe_unretained

2011-10-30 Thread James Merkel
Ok thanks. Not changing anything is the easiest and safest approach. Jim Merkel On Oct 30, 2011, at 10:52 AM, Dave Zarzycki wrote: > On Oct 30, 2011, at 10:32 AM, James Merkel wrote: > >> The document on ARC talks about problematic C structs like: >> >> struct x { NSString *S; int X; } Stati

Re: C struct and __unsafe_unretained

2011-10-30 Thread Dave Zarzycki
On Oct 30, 2011, at 10:32 AM, James Merkel wrote: > The document on ARC talks about problematic C structs like: > > struct x { NSString *S; int X; } StaticArray[] = { > @"foo", 42, > @"bar, 97, > ... > }; > > I use that pattern quite a bit in my code and haven't had any problems with > it. T

Re: C struct and __unsafe_unretained

2011-10-30 Thread James Merkel
On Oct 30, 2011, at 10:41 AM, Charles Srstka wrote: > On Oct 30, 2011, at 12:32 PM, James Merkel wrote: > >> struct x { NSString *S; int X; } StaticArray[] = { >> @"foo", 42, >> @"bar, 97, >> ... >> }; >> >> I use that pattern quite a bit in my code and haven't had any problems with >> it. Th

Re: C struct and __unsafe_unretained

2011-10-30 Thread Charles Srstka
On Oct 30, 2011, at 12:41 PM, Charles Srstka wrote: > @interface MyClass : NSObject > > @property (strong) NSString *someString; > @property NSInteger someInteger; > > @end That should have been copy, not strong. Sorry, I’m apparently not firing on all cylinders today. Charles

Re: C struct and __unsafe_unretained

2011-10-30 Thread Charles Srstka
On Oct 30, 2011, at 12:32 PM, James Merkel wrote: > struct x { NSString *S; int X; } StaticArray[] = { > @"foo", 42, > @"bar, 97, > ... > }; > > I use that pattern quite a bit in my code and haven't had any problems with > it. These are basically constant strings that never change. > > With

Re: C struct and __unsafe_unretained

2011-10-30 Thread Alex Kac
Its just making it clear that these are unretained. Make a #define to make it nice and clean like. But they are saying to make an objective C class mostly for people who do manual retain/releases in a struct so that its automatic. Finally, NSDictionary doesn't support that - but CFDictionary doe

Re: C struct and __unsafe_unretained

2011-10-30 Thread Jeff Kelley
The recommendation is to replace the struct with a class. So you would replace x with a class that might look like this: > @interface ReplaceX : NSObject > > @property (copy) NSString *label; > @property int value; > > @end This aside, you should be OK using __unsafe_unretained in an App Store