How do I know when I put my properties and methods in a .h file and when to put them in the .m interface?

How do I know when I put my properties and messages in a .h file and when to put them in the .m interface?

I think messages that are publicly available, like init, should be in the .h file. What about the properties that describe the class, for example. type of configuration, etc.

+4
source share
2 answers

If you want to restrict access to any property, you can define this in a .m file with extension extension, etc.

As such a rule, defined for placing properties in .h or .m files, there is no need to check which properties you want to get outside the class (specify them in .h) and which you want to access from the outside (define in .m).

+2
source

According to Apple docs, ads are declared in the @interface (.h) files. If you want to have only private objects, then they are called ivars, and you will not synthesize them for them.

Private properties (or "property overrides" in documents) can be used in such things as class extensions or protocols.

+1
source

Source: https://habr.com/ru/post/1412944/


All Articles