Re: NSError help
Re: NSError help
- Subject: Re: NSError help
- From: Ken Thomases <email@hidden>
- Date: Sun, 24 Oct 2010 18:05:19 -0500
On Oct 24, 2010, at 5:54 PM, Tom Jones wrote:
> I'm trying to understand why I'm getting thrown in to the debugger when using NSError. I have three methods and I'm overloading them and trying to pass the NSError along the way. What am I doing wrong?
> -(NSString *)getDataForType:(NSString *)aType error:(NSError **)err
> {
> NSError *localErr = nil;
> NSString *result = [self getDataForType:aType separator:@"\t" excludeFields:nil error:&localErr];
> *err = *localErr;
This is incorrect. The left and right sides are of two different types. The compiler should have at least warned, if not given an error.
"*localErr" is an NSError. It's not an NSError* (pointer to NSError), it's actually the type of the object (or struct). There's almost never a case to dereference an object pointer like this.
"*err" is an NSError*, a pointer to an NSError.
What you wanted is:
*err = localErr;
Actually, if you're not doing more with localErr, you can just eliminate it and just do:
NSString *result = [self getDataForType:aType separator:@"\t" excludeFields:nil error:err];
The same mistake affects the next method, too.
> return result;
> }
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden