Something you can clean up before taking your debugging further. In
> - (BOOL) saveToURL:(NSURL *)url ofType:(NSString *)typeName
> forSaveOperation:(NSSaveOperationType)saveOperation
> error:(NSError **)outError {
You repeatedly test outError for nil, apparently in the belief that this will
indicate whether an error has occurred. This is _never_ the case. The only
indicator that an error has occurred is the return value of the method. The
NSError* return is merely a description of what went wrong. The method is not
obliged to clear the error return upon success, and is entitled to set it even
upon success.
But you aren't doing even that:
> NSData * data = [attributedText dataFromRange:NSMakeRange(0,
> [attributedText length]) documentAttributes:nil error:outError];
>
> if( outError ) {
> [NSApp presentError:*outError];
> outError = nil;
> }
outError is not an NSError*, it is a _pointer_ to an NSError* variable. It is
your caller's request that you create an NSError* and pass it back if your
method fails. Assuming the caller asked for an NSError return, it will _always_
be non-nil, and your code will _always_ take its error-handling path. Fix that
before you try anything else.
I'm not clear on your intention on clearing-out the outError parameter. Is it
just to block the presentError: later in the method? Because (outError) will
always evaluate true, it will always be nilled-out, and the
writeToURL:atomically:encoding:error: (success/failure discarded in your code)
won't be able to report an error. And you're calling it regardless of whether
you seemingly believe there is an error or not.
> NSLog(@"%@ [%04d] %@ %@",[self className],__LINE__,
> NSStringFromSelector(_cmd),page);
Try:
NSLog(@"%s [%04d] - %@", __PRETTY_FUNCTION__, __LINE__, page);
— F
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]