iPod:NS_NONATOMIC_IPHONEONLY是什么意思?在iPod Touch上使用这样的属性是否安全?

six*_*ude 3 iphone ipod-touch

在CLLocation Class Reference属性部分下面,它的内容是coordinate:

coordinate
The geographical coordinate information. (read-only)

@property(readonly, NS_NONATOMIC_IPHONEONLY) CLLocationCoordinate2D coordinate
Discussion
When running in the simulator, Core Location assigns a fixed set of coordinate values to this property. You must run your application on an iOS-based device to get real location values.

Special Considerations
In iOS, this property is declared as nonatomic. In Mac OS X, it is declared as atomic.
Run Code Online (Sandbox Code Playgroud)

我只是好奇这意味着什么:@property(readonly, NS_NONATOMIC_IPHONEONLY).特别是NS_NONATOMIC_IPHONEONLY部分.在我看来,我可以从iPod touch访问它.

我错过了什么吗?从iPod touch使用它是否安全?

gca*_*amp 5

CoreLocation在Mac OS X和iOS(néeiPhoneOS)上共享.

在这里,NS_NONATOMIC_IPHONEONLY只表示iOS和非Mac OS X上的原子是非原子的.这里的iPhone仅指iOS,而不是iPhone和iPod touch.

它在TargetConditionals.h中定义为此.

// Marks APIs whose iPhone versions are nonatomic, that is cannot be set/get from multiple threads safely without additional synchronization
#if !defined(NS_NONATOMIC_IPHONEONLY)
    #if TARGET_OS_IPHONE
    #define NS_NONATOMIC_IPHONEONLY nonatomic
    #else
    #define NS_NONATOMIC_IPHONEONLY
    #endif
#endif
Run Code Online (Sandbox Code Playgroud)