TheAmazingAudioEngine / TheAmazingAudioEngine2

The Amazing Audio Engine is a sophisticated framework for iOS audio applications, built so you don't have to.
http://theamazingaudioengine.com/doc2
Other
544 stars 87 forks source link

Would you consider using NS_UNAVAILABLE and NS_DESIGNATED_INITIALIZER? #24

Closed jackpal closed 8 years ago

jackpal commented 8 years ago

Today I made a mistake by initializing an oscillator module in a test program as follows:

[[AEOscillatorModule alloc] init];

That compiled fine, but it didn't work (as I found out after debugging) because the oscillator module doesn't get initialized fully.

I should have written this instead:

[[AEOscillatorModule alloc] initWithRenderer:renderer];

Would you consider adding

- (instancetype)init NS_UNAVAILABLE;

and maybe also

NS_DESIGNATED_INITIALIZER

in all the appropriate places in your public headers?

michaeltyson commented 8 years ago

Excellent idea

hashmal commented 8 years ago

In this particular case, renderer is marked as nullable, which means that init does not necessarily needs to be marked as unavailable. It could just call initWithRenderer:nil instead.

However, the last time I tried to pass nil to the initializer, my program crashed.