5

Hi I've seen two ways to declare hidden instance variables in the .m file 1)

@interface MyClass() 
{
  //my ivars
}
@end
@implementation MyClass 
 //my implementation
@end

2)

@implementation MyClass
{
 //my ivars
}
 //my implementation
@end

Confused as to the difference between the two, and/or coding conventions when it comes to this. Thanks for any help!

4

1 に答える 1

0

良い質問!で宣言されたインスタンス変数を見る傾向がありますがinterface、明らかにimplementation動作します。この問題に関する私の考え:

  1. interfaceを使用する方が良いと思います
  2. で宣言された ivar はサブクラスにアクセスできないと思いますimplementation
于 2013-08-15T20:49:43.180 に答える