If you have a look at decodeBytesForKey:returnedLength:
you would see that returnedLength
is a NSUInteger*
and you're passing an integer. Besides the method returns const uint8_t*
, so you need to dereference it to get back your data.
Instead of
[self setMAudioUnit:(AudioUnit)[aDecoder decodeBytesForKey:@"mAudioUnit" returnedLength:sizeof(AudioUnit)]];
it should be
NSUInteger szAudioUnit;
const uint8_t* audioUnitBytes = [aDecoder decodeBytesForKey:@"mAudioUnit" returnedLength:&szAudioUnit];
AudioUnit* pAudioUnit = (AudioUnit*)audioUnitBytes;
self.mAudioUnit = *pAudioUnit;
Actually I don't know how you code even compiled !
On a side note, maybe just my opinion, it's not a convention in Objective-C to name properties with an m
prefix.