Wednesday 15 June 2011

ios - Using NSCoding with Core Audio Types -


I created a square that has three properties which are core audio types:

  @ Interface audiofile player: NSBJack & lt; Nscding & gt; @ Property (assign) audio usenet maudioanet; @ Property (assign) anode amnode; @ Property (Assign) AudioStream Basic Description mStreamFormat; @end   

I have an array of Odiofailpleyr types of objects in my app and I want to store them using Ansisoding and unarchive. sizeof:;: (NSCoder *) aCoder {[aCoder encodeBytes: _mAudioUnit length (uint8_t *) & amp - and initWithCoder :: This method (zero) encodeWithCoder

  I wrote EncodeWithCoder (Odiounit ): @ "Maudoniant"]; [Ecodar encodities: (uint8_t *) & amp; _mNode Length: key for sizeof (AUNode): @ "mNode"]; [Ecodar encodities: (uint8_t *) & amp; _mStreamFormat Length: sizeof (Audiostream Basic Description) forKey: @ "mStreamFormat"]; } - (id) initWithCoder: (NSCoder *) aDecoder {self = [super init]; If (self) {[self Setmaudiounet: (Odiounit) [Adikoder Dikodbaitsforki: @ "Amayudiounit" returned the went length size (audio Unet)]]; [Self Setmneod: (Aanodiad) [Adikoder Dikodbaitsforki: @ "Manod" has returned length Akarf (Aanodio)]]; [Self setMStreamFormat: * (AudioStreamBasicDescription *) [aDecoder decodeBytesForKey: @ "mStreamFormat" returnedLength: sizeof (AudioStreamBasicDescription)]]; } Healthy return; }   

I am able to successfully encode / encode (It is to say that a file has been written and no error has happened ... I am not sure that this is actually is working), but when I tried to object to launch the app and decode / non-collagenous, with app crash:

  thread 1: EXC_BAD_ACCESS (code = 2, address = 0x4 ) In my  initWithCoder method :  
  [self setMAudioUnit : (AudioUnit) [aDecoder decodeBytesForKey: @ "mAudioUnit" returnedLength: sizeof (AudioUnit)];   

This is my first time using NSCoding, so I am not completely believing that I am also doing this correctly.

These three core audio data types are Structures, so using the "bytes" version of encoding / init NSCoder methods looks like going right.

Any thoughts where I am going wrong?

Thanks in advance thanks!

After

you have a look at decodeBytesForKey, then: returnedLength: you will see that Returned length is a NSUINTENGER * and you are passing an integer. If the method returns constants is uint8_t * , then you need to get your data back to it, besides

  [instead of self setMAudioUnit : (Audiuneut) [Edikoder decodbieforki: @ "MusicUnitTit" is returned length: size (audio usenet)]];   

should be

  NSUInteger szAudioUnit; Const uint8_t * AUDIOnitBits = [ADCoder decodbiedForki: @ "MODUOONITIT" has been returned Lang: & amp; SageAudio unit]; AudioUnit * pAudioUnit = (AudioUnit *) AudioUnitBite; Self.mAudioUnit = * pAudioUnit;   

Actually, I do not know how you compile the code!

One note, maybe my opinion, this objective- is not a conference in C. Properties with a m prefix.

No comments:

Post a Comment