Normally we use
@interface interface_name : parent_class <delegates>
{
......
}
@end
method in .h file and in .m file we synthesis the properties of variables declared in .h file.
But in some code, this @interface…..@end method is kept in the .m file also. What does it mean? What is the difference between them?
Also give some words about getters and setters for the interface file that is defined in .m file…
It’s common to put an additional
@interfacethat defines a category containing private methods:Person.h:
Person.m:
The ‘private category’ (the proper name for a nameless category is not ‘private category’, it’s ‘class extension’) .m prevents the compiler from warning that the methods are defined. However, because the
@interfacein the .m file is a category you can’t define ivars in it.Update 6th Aug ’12: Objective-C has evolved since this answer was written:
ivarscan be declared in a class extension (and always could be – the answer was incorrect)@synthesizeis not requiredivarscan now be declared in braces at the top of@implementation:that is,