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

时间:2010-11-28 15:27:02

标签: 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.

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

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

1 个答案:

答案 0 :(得分:5)

CoreLocation在Mac OS X和iOS(适用于iPhone OS)上共享。

在这里,NS_NONATOMIC_IPHONEONLY仅表示在iOS OS上是非原子的,在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