Hi All: Current bridging from Objective-C to Swift has this behaviour:
If we define a property in Objective-C, and we don’t say it is nullable or nonnull, like this: @property (nonatomic, strong, readonly) NSString *someString; When we reference it from Swift, this property will be bridging to* String!* (*implicitly unwrapped optional*) type automatically, and *there is no warning indicate we should check if this is nil first.* So the result is when some edge cases happen, the App will crash. As more and more large projects are trying to use Swift now, this may seems a problem for more people. The documents I can find is: https://developer.apple.com/swift/blog/?id=25 and https://developer.apple.com/library/content/documentation/ Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html, it says “Swift cannot distinguish between optional and nonoptional references, and imports it as an implicitly unwrapped optional.” As in Objective-C, the default property is nullable(if you don’t say it is nonnull), I am curious what’s the reason that the property is not bridging to optional, for me, feel optional value should be a better fit here. Anyone know what’s the consideration at Swift 2 when this change happens? Regards, olddonkey
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users