I want to know the difference between creating classes in iphone.
@interface classA (UIView){
}
@end
and
@interface classA : UIView {
}
@end
Does anyone know the exact different between these two?
Thanks in advance
The first block of code is used to create category. and second block is used to create classes in objective c. With the help of category you can add methods to the existing classes.
Your first example would be wrong.
You would use the first one to create a category, and could be used like this:
@interface UISwitch (PrivateMethods)
-(void)setAlternateColors:(BOOL)alternateColors;
@end
Where as your second example is your own class:
@interface MyClass : UIView
{ /* pointers */ }
@end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.