Why are objective-c @interface definitions placed in a seperate .h file? -


i recognize general type of question i'd interested in opinion on:

  • why @interface @protocol , @property definitons seperated .h header file , imported implementation file?

is there out there defines in .m file?

btw> not planning on not using .h files, trying understand thinking behind it!

because objective-c relies on standard c infrastructure in every compilation unit (.m) compiled separately , of them linked together.

this means static type checking phase of objective-c compiler need .h files know characteristics of declared classes (eg. signatures of methods) ensure used supposed be, , why #import them in other source files require declared inside header.

if have a.h/.m , b.h/.m uses can think of header file contract: "if want use a, link binary code @ end of compilation phase, able provide described in header file , thing should know"


Comments