Re: odd behavior with NSError?

2009-10-16 Thread mmalc Crawford
On Oct 15, 2009, at 10:41 pm, Nathan Vander Wilt wrote: Ouch. So the following pattern is incorrect? NSError* internalError = nil; (void)[foo somethingReturningBool:bar error:internalError]; if (internalError) { // ... }

Re: odd behavior with NSError?

2009-10-16 Thread Greg Guerin
Bill Bumgarner wrote: On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote: ... You're saying that some methods go out of their way to trample my (potentially unavailable) error storage even on success? If the error storage is not available, as indicated by passing an NSError** of nil,

Re: odd behavior with NSError?

2009-10-16 Thread Ben Trumbull
(response is pedantic for the purposes of the archive :) even more better flaming pedanticism! On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote: Ouch. So the following pattern is incorrect? Yes; it is incorrect. NSError* internalError = nil; (void)[foo somethingReturningBool:bar

Re: odd behavior with NSError?

2009-10-16 Thread Rob Keniger
On 16/10/2009, at 4:45 PM, Ben Trumbull wrote: Other people have different perspectives on local variable initialization. Wrong perspectives, but different. Fortunately now, they waste their arguments upon the merciless http://llvm.org/img/DragonFull.png Clangdor the Burninator.

Re: odd behavior with NSError?

2009-10-16 Thread Kevin Bracey
If we get an NSError, or in the case of NSAppleScript an NSDictionary with the error description, what is the Retain count and do we release it when we're done with it? I'd been not releasing them, I didn't allocate or copy it, but when I Build and Analyzed my code in 3.2 on Snow Leopard

Re: odd behavior with NSError?

2009-10-16 Thread Jerry Krinock
On 2009 Oct 16, at 03:44, Kevin Bracey wrote: If we get an NSError, or in the case of NSAppleScript an NSDictionary with the error description, what is the Retain count The retain count of an object is equal to 1 for alloc + the number of - retain messages - the number of -release messages

Re: odd behavior with NSError?

2009-10-16 Thread Greg Guerin
Kevin Bracey wrote: If we get an NSError, or in the case of NSAppleScript an NSDictionary with the error description, what is the Retain count and do we release it when we're done with it? Wrong question. The retain count is not an ownership count. The right question is Do I own it?

Re: odd behavior with NSError?

2009-10-15 Thread Nathan Vander Wilt
On Oct 2, 2009, at 7:45 AM, Bill Bumgarner wrote: In either case, assuming the undefined reference is nil would be a bug. Initializing the variables to nil prior to the call isn't going to change anything in that regard. (And, yes, there are methods that modify their error parameter on

Re: odd behavior with NSError?

2009-10-15 Thread Bill Bumgarner
(response is pedantic for the purposes of the archive :) On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote: Ouch. So the following pattern is incorrect? Yes; it is incorrect. NSError* internalError = nil; (void)[foo somethingReturningBool:bar error:internalError]; if (internalError)

Re: odd behavior with NSError?

2009-10-15 Thread Kyle Sluder
On Thu, Oct 15, 2009 at 10:41 PM, Nathan Vander Wilt nate-li...@calftrail.com wrote: Ouch. So the following pattern is incorrect? NSError* internalError = nil; (void)[foo somethingReturningBool:bar error:internalError]; if (internalError) { Indeed, this is very incorrect. If the existence

Re: odd behavior with NSError?

2009-10-02 Thread Gregory Weston
Stephen J. Butler wrote: On Thu, Oct 1, 2009 at 10:31 PM, Colin Howarth co...@howarth.de wrote: NSStringEncoding *enc; NSError *error; NSString *file = [NSString stringWithContentsOfFile:@/Users/colin/developer/Trace/glass.csv usedEncoding:enc error:error]; The way you

Re: odd behavior with NSError?

2009-10-02 Thread Bill Bumgarner
On Oct 2, 2009, at 4:05 AM, Gregory Weston wrote: While we're at it, the values of enc and error are (effectively) nondeterministic before the message send. The documentation for the method you're invoking doesn't specify what it'll put into the encoding argument on failure or into the

Re: odd behavior with NSError?

2009-10-02 Thread Matt Neuburg
On Fri, 02 Oct 2009 07:05:37 -0400, Gregory Weston gwes...@mac.com said: Stephen J. Butler wrote: On Thu, Oct 1, 2009 at 10:31 PM, Colin Howarth co...@howarth.de wrote: NSStringEncoding *enc; NSError *error; NSString *file = [NSString

Re: odd behavior with NSError?

2009-10-02 Thread Jens Alfke
On Oct 2, 2009, at 4:05 AM, Gregory Weston wrote: It would be a good idea to get into the habit of initializing your local variables at the point of declaration. At the risk of starting a religious debate, I disagree. It makes the code somewhat bigger and slower, and worse, it can mask

Re: odd behavior with NSError?

2009-10-02 Thread Colin Howarth
On 2 Oct, 2009, at 07:36, Stephen J. Butler wrote: On Thu, Oct 1, 2009 at 10:31 PM, Colin Howarth co...@howarth.de wrote: NSStringEncoding *enc; NSError *error; NSString *file = [NSString stringWithContentsOfFile:@/Users/colin/developer/Trace/glass.csv usedEncoding:enc

odd behavior with NSError?

2009-10-01 Thread Colin Howarth
Hi, I'm trying to read a file using this code, which is failing: NSStringEncoding *enc; NSError *error; NSString *file = [NSString stringWithContentsOfFile:@/Users/colin/ developer/Trace/glass.csv usedEncoding:enc error:error]; NSLog(@%i: %@,

Re: odd behavior with NSError?

2009-10-01 Thread Kyle Sluder
Because userInfo is a dictionary and is obviously not what you want. Using `po` winds up calling -description, which for NSError returns a synthesis of its localizedDescription, localizedFailureReason, localizedRecoveryOptions, and localizedRecoverySuggestion. So if you want that info, just log

Re: odd behavior with NSError?

2009-10-01 Thread Quincey Morris
On Oct 1, 2009, at 20:31, Colin Howarth wrote: Why is my NSLog statement being so unhelpful??? Try logging [error localizedDescription] instead. That's what the debugger's showing you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Re: odd behavior with NSError?

2009-10-01 Thread Stephen J. Butler
On Thu, Oct 1, 2009 at 10:31 PM, Colin Howarth co...@howarth.de wrote:        NSStringEncoding *enc;        NSError *error;        NSString *file = [NSString stringWithContentsOfFile:@/Users/colin/developer/Trace/glass.csv usedEncoding:enc error:error]; The way you pass enc is also wrong.