开发者

Different between implementing two class in iphone

I want to know the difference between creating classes in iphone.

@interface classA (UIView){

}

@end

and

@interface classA : UIView {

}

@end

开发者_StackOverflow中文版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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜