• 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: 'nuther dumb question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'nuther dumb question


  • Subject: Re: 'nuther dumb question
  • From: Graham Cox <email@hidden>
  • Date: Sat, 17 May 2014 13:21:31 +1000

[NSString dataUsingEncoding:]

sometimes you have to look at the source object, not the destination (in fact usually, I'd say).

Also, in this case, [NSData initWithString:] would lack the information needed to perform the conversion - you need to pass in what encoding you require.

--Graham




On 17 May 2014, at 9:46 am, William Squires <email@hidden> wrote:

> Why doesn't NSData have a +[NSData dataWithString:(NSString *)] or -[NSData initWithString:(NSString *)] method? i.e. how do I convert the contents of an NSString object into an NSData object? Why? Because -[NSFileHandle writeData:(NSData *)] takes an NSData object, not an NSString object. Arrrgghhhh. :(
>  Also, how come NSFileHandle doesn't have a -[NSFileHandle readFileWithSeparator:(NSString *)] method so one can read in only chunks of a file (of varying size, such as CSV records, or lines in a text file, separated by \n, as opposed to a fixed size, which could be accomplished with -[NSFileHandle readDataOfLength:(NSUInteger)] instead), instead of having to read in the whole thing? Especially on iOS, where memory space is at a premium!
>  This seems like a major oversight to me... unless maybe there's a class which provides a higher-level of abstraction, such as NSTextFileHandle? Yeah, I can drop down to the C-level fopen(), fread(), fwrite(), fclose() etc... functions, but I'm looking for an OO-way to do this.


_______________________________________________

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: 
 >'nuther dumb question (From: William Squires <email@hidden>)

  • Prev by Date: Re: Not getting mouseDown: called when control-clicking in view in menu item
  • Next by Date: Re: 'nuther dumb question
  • Previous by thread: Re: 'nuther dumb question
  • Next by thread: Re: 'nuther dumb question
  • Index(es):
    • Date
    • Thread