December 2018
Intermediate to advanced
414 pages
10h 19m
English
We can use NS_ASSUME_NON_NULL_BEGIN and NS_ASSUME_NON_NULL_END in order to express broadly that all properties, method arguments, and return types are non-optional:
NS_ASSUME_NONNULL_BEGIN@interface AnObject: NSObject- (NSString *)sayHello; // return @”Hello World”- (NSString *)append:(NSString *)aString with:(NSString *)anotherString;@endNS_ASSUME_NONNULL_END
The following snippet shows how to use it in Swift:
// Swift 5let object = AnObject()let string = object.sayHello() // Stringlet returnValue = object.append("First String", with: "Next String")let otherString = string.appending(" From Swift") // safe to useassert(otherString == "Hello World From Swift")
As you can see, nothing ...
Read now
Unlock full access