Re: Converting NSArray of NSString elements into binary?
Re: Converting NSArray of NSString elements into binary?
- Subject: Re: Converting NSArray of NSString elements into binary?
- From: Bill Bumgarner <email@hidden>
- Date: Mon, 1 Oct 2007 19:25:02 -0700
On Oct 1, 2007, at 7:22 PM, R.L. Grigg wrote:
On Oct 1, 2007, at 7:10 PM, Bill Bumgarner wrote:
On Oct 1, 2007, at 7:04 PM, R.L. Grigg wrote:
On Oct 1, 2007, at 6:05 PM, Nick Zitzmann wrote:
On Oct 1, 2007, at 5:28 PM, R.L. Grigg wrote:
Is there some method to convert the NSArray of NSString
elements into binary byte values?
No.
Or do I have to go through each element and convert each
NSString into a NSNumber so I can put it's byteValue into a
NSMutableData one by one? Is this the wrong approach?
Using NSNumber is a little extreme; just using -intValue ought
to cover things unless you need 64-bit integers.
Hmm, I wish there was a -charValue method for NSString. This
still needs a step to go from the integers that intValue gives me
to byte values for putting into NSData. I guess there's no
graceful way to accomplish this.
I may be missing something, but you could always archive the
NSArray instance using NSArchiver (then unarchive via NSUnarchiver).
Yah -- that'll bloat the size a bit, but you'll not have to deal
with any endianness issues, etc...
Wow now I'm confused. If these are byte values in NSData how does
the endianness factor in?
It probably doesn't -- I didn't parse that word. :)
But, still, the least # of lines of code would be NSArchiver/
NSUnarchiver. The question boils down to what you want to do with
the NSData. If you need to interpret the contents outside using
NSUnarchiver, then you'll need to do something more manual.
If you just need an array of bytes, malloc() isn't that hard.
b.bum
_______________________________________________
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