When I create new classes in x-code it breaks it into a .h and a .m file. can I ignore the .h file and implement the entire class inside the .m file? If so what are the downsides?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is absolutely possible to implement the whole class in a single .m file just as it is possible to implement an entire c++ class in a .cc file. The major disadvantage is that you lose the decoupling of interface and implementation. Another major disadvantage is that you will need to repeat the same interface code in any other .m file that utilizes the class. In other words you lose the ability to simply import the .h file in any other class file.