官术网_书友最值得收藏!

Using nullable, nonnull, _Nullable, and _Nonnull

With NS_ASSUME_NON_NULL_BEGIN/_END, you may need to mark particular properties as nullable as all of the code enclosed will be translated without optionals.

These four keywords are used to mark individual arguments or properties—their usage is straightforward:

  • nullable
  • nonnull
  • _Nullable
  • _Nonnull

Using a nullable property will produce Optional, which you'll safely need to unpack in Swift. Using nonnull will produce non-optional properties or variables. nullable and nonnull keywords are exclusively used in the context of declaring @property on Objective-C interfaces. 

_Nullable and _Nonnull keywords are used in all other cases:

  • Declaring local variables
  • Arguments to methods
  • Return types of methods
  • Declaring ivars

You can use the following table as a reference if you ever need to quickly look up the different possibilities and how they translate in both languages:

主站蜘蛛池模板: 香港| 肃南| 株洲县| 德化县| 汉沽区| 福安市| 钦州市| 普格县| 吉隆县| 卓尼县| 永善县| 南郑县| 乌恰县| 永登县| 琼中| 高阳县| 康保县| 开远市| 瑞金市| 海淀区| 渭源县| 工布江达县| 循化| 平遥县| 南宫市| 浑源县| 木里| 隆回县| 临沂市| 武宁县| 方山县| 玛多县| 鱼台县| 扬州市| 克拉玛依市| 湛江市| 莱阳市| 琼结县| 阿巴嘎旗| 县级市| 谷城县|