Re: string pointer


On 7 Mar 2018, at 17:47, Jens Alfke <jens@...> wrote:

On Mar 7, 2018, at 2:24 AM, Dave <dave@...> wrote:

I disagree that it's dangerous. It's the standard way code is written when a parameter is passed back by reference. How many times in Apple code do you see something like:

Just because you see it in “Apple Code” doesn’t mean its the best or safest way of doing something. Just look at the quality of code coming out of Apple these days, its awful, in fact just look at the mess that is called XCode! 

Without having used any apps you've written, I can't compare.

The difference is in the amount of resources available to each of us. If you were to take into account he reliability of my software given the amount of resources I have available then I’d score over Apple on a scale of at least 1000% 

And 'out' parameters are widely used in Cocoa programming, not just by Apple.

I’m not complaining about “out” parameters, just autorelease! 

Autoreleasing bugs are really difficult to find which is why I avoid using AU like the plague! 

I honestly don't see anything dangerous about the code in question. And your "ticking time bomb" explanation makes no sense to me (and I've been using Cocoa since 2000.) There's no difference between an autoreleased pointer that you get as the return value of a function, vs. one that comes from an 'out' parameter like this.

Its been ages since I’ve had to deal with it and I am talking pre ARC which takes care of 99% of the worry of using Auto Release. But the problem occurred when you assigned the object returned in that manner to a property or iVar and didn’t retain it. If you accessed  before had been released by AU, it worked ok, but if it was a while later (usually in response to a notification) it causes a crash. At that point its hard to know what the cause of crash is whereas if it is released manually you’d get the crash near the point of the bug a very short time afterwards. I think the NSError class is more prone to these crashes because it typically isn’t accessed a lot after the event.



Join to automatically receive all group messages.