Possible Duplicate:
Difference between @interface definition in .h and .m file
What is the @interface declaration in .m files used for in iOS 5 projects?
I've seen code like this:
// In Header.h
@interface Header{}
@end
// In Header.m
@interface Header()
@end
My questions are:
@interface MyClass(){
NSInteger aInt;
}
@property(nonatomic,strong) NSString *name;
@end
is a class extension
with modern compilers this is a great way, to decrale methods, ivars and properties only for private use in the class MyClass.
Class extensions have to be declared in the main implementation file (not in a category).
So you can hide implementation details from the header file, they are private.
This has become a common practice for declaring "private" properties/methods for a given class. By declaring them in an anonymous class extension inside the .m, these properties/methods are not exposed to consuming objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With