Re: Retain count in non ARC

2014-04-07 Thread Gerd Knops
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html#//apple_ref/doc/uid/TP40011210-CH5-SW3 and scroll up about half a page: "Properties Are Atomic by Default" gerd On Apr 7, 2014, at 6:56 PM, Graham Cox wrot

Re: Retain count in non ARC

2014-04-07 Thread Graham Cox
On 8 Apr 2014, at 6:11 am, Greg Parker wrote: > No. atomic is the default everywhere. Do you have a reference for the relevant documentation? I don't know if it's a reflection on me or Xcode's doc search, but I simply couldn't find it (though I'm pretty sure I have read it somewhere). --Gra

Re: Retain count in non ARC

2014-04-07 Thread Greg Parker
On Apr 7, 2014, at 1:52 AM, Kevin Meaney wrote: > I thought the behaviour was different between iOS and MacOS. On iOS nonatomic > was the default and atomic on OS X. No. atomic is the default everywhere. The only OS difference is that the iOS SDK tends to use nonatomic more than the OS X SDK.

Re: Retain count in non ARC

2014-04-07 Thread Kevin Meaney
I thought the behaviour was different between iOS and MacOS. On iOS nonatomic was the default and atomic on OS X. Kevin Sent from my iPhone On 7 Apr 2014, at 05:28, Graham Cox wrote: > > On 7 Apr 2014, at 1:58 pm, Ben Kennedy wrote: > >> t is for these two reasons that, from years of condi

Re: Retain count in non ARC

2014-04-06 Thread Charles Srstka
On Apr 6, 2014, at 11:28 PM, Graham Cox wrote: > On 7 Apr 2014, at 1:58 pm, Ben Kennedy wrote: > >> t is for these two reasons that, from years of conditioning, I can watch my >> fingers type "(nonatomic " automatically and as if my magic as soon as I >> finish typing "@property " ... > > Me

Re: Retain count in non ARC

2014-04-06 Thread Graham Cox
On 7 Apr 2014, at 1:58 pm, Ben Kennedy wrote: > t is for these two reasons that, from years of conditioning, I can watch my > fingers type "(nonatomic " automatically and as if my magic as soon as I > finish typing "@property " ... Me too, though it's been more to do with the fact that I don'

Re: Retain count in non ARC

2014-04-06 Thread Ben Kennedy
On 06 Apr 2014, at 8:44 pm, Graham Cox wrote: > I thought about mentioning it, but figured it might already sound a bit > complicated. Isn't 'nonatomic' the default? If not, I can't actually find the > documentation about it. Also, if 'atomic' is the default, won't performance > suffer with al

Re: Retain count in non ARC

2014-04-06 Thread Graham Cox
On 7 Apr 2014, at 1:25 pm, Ken Thomases wrote: > Usually, it's better/easier to simply declare the property nonatomic. I thought about mentioning it, but figured it might already sound a bit complicated. Isn't 'nonatomic' the default? If not, I can't actually find the documentation about it.

Re: Retain count in non ARC

2014-04-06 Thread Varun Chandramohan
Thanks guys, really appreciate it. On 7/04/2014 1:25 pm, "Ken Thomases" wrote: >On Apr 6, 2014, at 9:18 PM, Graham Cox wrote: > >> On 7 Apr 2014, at 10:35 am, Varun Chandramohan >> wrote: >> >>> @property (retain) NSArray* contents; >> >> Should be: >> >> @property (copy) NSArray* contents; >

Re: Retain count in non ARC

2014-04-06 Thread Ken Thomases
On Apr 6, 2014, at 9:18 PM, Graham Cox wrote: > On 7 Apr 2014, at 10:35 am, Varun Chandramohan > wrote: > >> @property (retain) NSArray* contents; > > Should be: > > @property (copy) NSArray* contents; > @synthesize contents = ivarContents; > > Having done that you'll now only have one ivar

Re: Retain count in non ARC

2014-04-06 Thread Graham Cox
On 7 Apr 2014, at 10:35 am, Varun Chandramohan wrote: > Hi Graham, > > Thank you for such detailed explanation. I made a few changes except the > type check of what NSPropertyListSerialization returns. Ill be adding that > soon. Other than that, I wanted you to take a look at the changes I mad

Re: Retain count in non ARC

2014-04-06 Thread Varun Chandramohan
Hi Graham, Thank you for such detailed explanation. I made a few changes except the type check of what NSPropertyListSerialization returns. Ill be adding that soon. Other than that, I wanted you to take a look at the changes I made and let me know if you see any problems. I tested it, at it seems

Re: Retain count in non ARC

2014-04-04 Thread John McCall
On Apr 3, 2014, at 8:22 PM, Varun Chandramohan wrote: > Interestingly, the static code analysis find the call of "retain" as a leak. > How do I address this issue? What is correct way to rewrite this code to make > static analyser understand that I will be releasing the resource? If I > remove

Re: Retain count in non ARC

2014-04-03 Thread Graham Cox
On 4 Apr 2014, at 2:40 pm, Graham Cox wrote: > Thirdly, casting the return value of [NSPropertyListSerialization > propertyListWithData...] to NSMutableArray doesn't turn that object into a > mutable array - you've just forced the type system to stop helping you. > Certainly retaining it here

Re: Retain count in non ARC

2014-04-03 Thread Graham Cox
On 4 Apr 2014, at 2:22 pm, Varun Chandramohan wrote: > @property (assign) NSMutableArray* contents; >[config setContents:(NSMutableArray *)[[NSPropertyListSerialization > > propertyListWithData:plistXML > >

Retain count in non ARC

2014-04-03 Thread Varun Chandramohan
Hi Guys, I was looking into an older project which does not use ARC and I noticed new static code analysis issues with leaks. Here is a little sample code of the object in question. @interface TempConfig : NSObject @property (assign) NSMutableArray* contents; +(id)newTempConfigWithSource:(