Do private ivars in Objective-C have atomic attribute by default (like properties)?

前端 未结 1 596
生来不讨喜
生来不讨喜 2020-12-21 17:21

Consider a scenario where I have some instance variable like this.

@implementation Foo {
    NSString *foo;
}

// Some code 

@end

I wanted

相关标签:
1条回答
  • 2020-12-21 18:02

    I wanted to know if this foo ivar would be atomic by default

    No, it would not. That is one of the (many) reasons for using a @property declaration instead of an ivar. With a @property declaration, you get an actual accessor method written for you behind the scenes, and this will be atomic by default.

    0 讨论(0)
提交回复
热议问题