'nuther dumb question

2014-05-19 Thread William Squires
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.

Re: 'nuther dumb question

2014-05-16 Thread Quincey Morris
On May 16, 2014, at 16:46 , William Squires wsqui...@satx.rr.com wrote: Why doesn't NSData have a +[NSData dataWithString:(NSString *)] or -[NSData initWithString:(NSString *)] method? Because strings consist of *encoded* data, which (in principle) has no meaning outside the internals of

Re: 'nuther dumb question

2014-05-16 Thread Sixten Otto
On Fri, May 16, 2014 at 4:46 PM, William Squires wsqui...@satx.rr.comwrote: 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? Try -[NSString

Re: 'nuther dumb question

2014-05-16 Thread Graham Cox
[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

Re: 'nuther dumb question

2014-05-16 Thread Graham Cox
On 17 May 2014, at 9:46 am, William Squires wsqui...@satx.rr.com wrote: 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

Re: 'nuther dumb question

2014-05-16 Thread Graham Cox
On 17 May 2014, at 9:46 am, William Squires wsqui...@satx.rr.com wrote: 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. Arrrgg. :( BTW, is there some reason you