Re: Tiger Decoding problem
Re: Tiger Decoding problem
- Subject: Re: Tiger Decoding problem
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 29 May 2005 19:28:44 -0700
On May 29, 2005, at 6:54 PM, Nicholas Crosbie wrote:
That makes sense. But how do I include the error
argument?
Ondra has addressed some of the issues, however:
int main (int argc, char *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *path = [NSString new];
NSError *myLog = [NSError new];
There is no need to create either a string or an error object --
simply declare the variables.
In the case of an NSError, it may be useful to ensure it's set to nil:
NSError *myLog = nil;
path = @"/Users/nicholas/test2/fileB";
You could have written:
NSString *path = @"/Users/nicholas/test2/fileB";
(in place of the original declaration and the line above).
NSString *contents = [NSString
stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding error:myLog];
The stringWithContentsOfFile:encoding:error: method (as is the case
with most methods taking an NSError argument) requires a pointer to a
pointer to an error (the argument is NSError **). Your code should be:
NSString *contents =
[NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:&myLog]; // note the "&"
/Users/nicholas/test2/test2.m:14: warning: passing
argument 3 of
'stringWithContentsOfFile:encoding:error:' from
incompatible pointer type
This is telling you that, in this case, you had not passed in an
NSError **.
Also, NSLog does not print to the Run Log the contents
of my decoded file. Why?
What does it print out?
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden