代码之家  ›  专栏  ›  技术社区  ›  sixtyfootersdude

iPod:非原子iphone的唯一含义是什么?在iPod Touch上使用这样的属性安全吗?

  •  3
  • sixtyfootersdude  · 技术社区  · 14 年前

    在里面 CLLocation Class Reference 在properties部分下面 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 回复  |  直到 14 年前
        1
  •  5
  •   gcamp    14 年前

    核心定位在Mac OS X和iOS(ne-iPhone操作系统)之间共享。

    在这里, NS_NONATOMIC_IPHONEONLY

    它在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