Re: EXC_BAD_ACCESS in NSData
Re: EXC_BAD_ACCESS in NSData
- Subject: Re: EXC_BAD_ACCESS in NSData
- From: Greg Parker <email@hidden>
- Date: Tue, 27 May 2014 12:08:52 -0700
On May 26, 2014, at 8:28 PM, Charles Srstka <email@hidden> wrote:
> On May 26, 2014, at 7:43 PM, Uli Kusterer <email@hidden> wrote:
>> Regarding endian-swapping, that depends on the file format. If you wrote that file yourself, you don’t usually need to do any swapping.
>
> That's true. For example, back in the PowerPC days, we never had to endian-swap our file formats, because we knew that our file format was created on a Mac, and Macs always used big-endian, and it wasn't as if Apple was ever going to do anything crazy like switch to Intel or anything.
>
> Nowadays, of course, we can be assured that our code will always run on Intel processors, because *obviously* there's no reason your code would ever need to run on something like ARM.
Note that most ARM platforms are little-endian nowadays, including iOS.
Untested code is incorrect code. Don't write endian-swapping code that you can't test because you aren't using any other-endian platforms today. It's expensive to spend engineer-hours to write endian code that is untested and therefore incorrect, or to write endian code plus endian tests in the fear that you'll need to port to such a platform someday.
Do you try to handle platforms where arithmetic is not two's-complement or where bytes are not 8 bits? I don't. The Next Big Thing might use them, but that's not the way to bet. Endianness is on the same scale, although admittedly not at that extreme.
If you're paranoid or you like portability, you should use a reading and writing abstraction that can be changed into an endian transformation if necessary in the future. More than that is unlikely to be worth the investment until you receive a credible threat of an other-endian platform that you care about.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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