• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: creating files to write data to?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating files to write data to?


  • Subject: Re: creating files to write data to?
  • From: Scott Anguish <email@hidden>
  • Date: Sun, 17 Aug 2008 02:07:02 -0400


On 17-Aug-08, at 1:52 AM, Ken Thomases wrote:

On Aug 17, 2008, at 12:07 AM, FTB Accounts wrote:

Here is the current code I am running:

This code has many fundamental errors. I think you need to review the basics of the C language first, then of Objective-C. You have to walk before you can run.


You say that you're not getting any errors or warnings when you build this, but that can't be. You would definitely get warnings for this code.

/* START CODE */

#import <Cocoa/Cocoa.h>

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

NSData *fname = "file:///Users/cknorr/mytest/MYTEST/data.txt";

You are initializing a variable of type NSData* (pointer to NSData). However, the right-hand side is not an NSData*, it's a C- style string, which is a character array (char* or char[]). These are not compatible. It's certainly not meaningful. Any attempt to use the fname variable as though it were a pointer to an NSData object would fail, because it doesn't actually contain a valid pointer to an NSData object.


NSFileHandle *fh=[NSFileHandle fileHandleForWritingAtPath:fname];

Even if fname did contain a valid pointer to an NSData object, the above would not be correct. The +fileHandleForWritingAtPath: method of NSFileHandle expects a pointer to an NSString object as its argument, but that's not what you're providing.

and file:/// is a URL string, not a file system path.


_______________________________________________

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


References: 
 >Re: creating files to write data to? (From: FTB Accounts <email@hidden>)
 >Re: creating files to write data to? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: creating files to write data to?
  • Next by Date: setNilValueForKey: not called when Number Formatter is nil
  • Previous by thread: Re: creating files to write data to?
  • Next by thread: Re: creating files to write data to?
  • Index(es):
    • Date
    • Thread