Objective-C实例变量与@interface变量

Objective-C实例变量与@interface变量,objective-c,Objective C,我是iOS编程新手,很难理解实例变量的区别。我给你举两个例子,你能解释一下有什么不同吗?(仅适用于非IBOutlet的实例变量) 在.m文件中 @interface MyClass () @property(nonatomic, strong) NSString *aString; @end @implementation MyClass { NSString *_aString; } 在.m文件中 @interface MyClass () @property(nonatom

我是iOS编程新手,很难理解实例变量的区别。我给你举两个例子,你能解释一下有什么不同吗?(仅适用于非IBOutlet的实例变量)

在.m文件中

@interface MyClass ()
  @property(nonatomic, strong) NSString *aString;
@end
@implementation MyClass
{
   NSString *_aString;
}
在.m文件中

@interface MyClass ()
  @property(nonatomic, strong) NSString *aString;
@end
@implementation MyClass
{
   NSString *_aString;
}
在这两种情况下,我都在.m文件中,并声明“instance”变量。但是,在@interface(.m文件)中声明它们和在@implementation中使用{}声明它们有什么区别呢


我排除了IBOutlet,因为@interface中只有一个变量(我猜…)

这个@interface变量被称为
属性
——因此
@属性

查看此来源以找出差异: