简体   繁体   English

在 iphone 中实现两个 class 的区别

[英]Different between implementing two class in iphone

I want to know the difference between creating classes in iphone.我想知道在 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.第二个块用于在目标 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:你的第二个例子是你自己的 class:

@interface MyClass : UIView 
{ /* pointers */ }
@end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM