This question may look silly, however I am not clear I don’t hesitate to ask this question. Including header file in one more header file, Is it a good practice. Usually I guess its not a good approach. In some cases it required to include header files.
eg: @property (strong, nonatomic) AVAudioPlayer *audio_player;
Consider I have property like this, When I include its corresponding header file in .mm file Xcode is showing undeclared error in .h file, so I’m here forced to include its header file in .h file itself. Because of this wherever I am including this class I also include indirectly audio player header file also, it may not require in that class. How can we avoid this. Or I can proceed like this…? Please provide a suggestion.
You don’t have to avoid this. It’s perfectly legal and idiomatic.
The logic behind this is that you may want to access the
audio_playerproperty of an instance of your class from another class, and if you didn’t do this, then the type of the property would be undeclared.