Hi,

I couldn't believe that you didn't get any warning so I did copy your code into xcode. Voila, I do get warnings!

My suggestion is read again the comments carefully and check the documentation.

It was mentioned before that [fh writedata ... needs a NSData ( or NSMutableData ) and not a string.

Also check the docs for [NSFileHandle fileHandleForWritingAtPath:] it needs a string. So fname should be a string.

You know that you can select the text in your code and then right/ control click to go to 'Find selected text.....'?

If you do then you can see that you need a NSString with the path and not a URL.

Also don't forget, that if your file does not exist, *fh will be nil!!

Good luck.

R

On 17 aug 2008, at 07:07, FTB Accounts wrote:

Thanks, all for the responses.

First I changed the path to write to. The folder is writable. On GetInfo for the folder "MYTEST", I have set "Read & Write" permissions for: You can, Owner, Group, & Others. Is there anything else I need to do to make it write to that folder?

As a side note, I am running an Apache server on the mac I am working on, and I can write PHP programs that will write to this directory.

However, this is still not working. I am not getting anything under "Errors and Warnings" in Xcode. Also the program loads. However, after running the Debugger does come up.

On debugger there are 5 listed.

0. asm objc_msgSend 0x90a594c0:1
1. ?
2. asm -[NSConcreteFileHandle initWithPath:flags:createMode:] 0x92867509:1
3. asm +[NSFileHandle fileHandleForWritingAtPath:] 0x9287a5e6:1
4. THIS IS BROKEN DOWN IN SUB SECTIONS

[Arguments]
Value: 1
Variable: argc
Value: 0xbffffa5c
Variable: argv
[Locals]
Value: 0x2cf58
Variable: fname
Summary: {(int)[$VAR length]} bytes
Value: 0x1f4c
Variable: fh
Summary: file descriptor: {(int)[$VAR fileDescriptor]}


Here is the current code I am running:

/* START CODE */

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{

        NSData *fname = "file:///Users/cknorr/mytest/MYTEST/data.txt";
        NSFileHandle *fh=[NSFileHandle fileHandleForWritingAtPath:fname];
        [fh writeData:@"THIS IS A TEST"];
        [fh closeFile];
        
   return NSApplicationMain(argc,  (const char **) argv);
}



--- On Sat, 8/16/08, Jason Coco <[EMAIL PROTECTED]> wrote:

From: Jason Coco <[EMAIL PROTECTED]>
Subject: Re: creating files to write data to?
To: "Andy Lee" <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED], cocoa-dev@lists.apple.com
Date: Saturday, August 16, 2008, 3:33 AM
On Aug 15, 2008, at 19:35 , Andy Lee wrote:

On Aug 15, 2008, at 6:43 PM, Jason Coco wrote:
Adding the @ just makes it an NSString constant...
but writeData
still requires (NSData *), not (NSString *).

Argh!  Or perhaps, given the nature of this error,
which I missed, I
should say "Arg!"

Surely you got a compiler warning?  If you ignored
that, surely a
runtime error?

Check your errors, both at compile time and runtime
(and treat
warnings as errors).

Yeah... I was thinking the same thing... you /must/ have
got
warnings... eventually you would have gotten an Exception I
think :)



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/appledev%40xs4all.nl

This email sent to [EMAIL PROTECTED]


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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]

Reply via email to