Last active
August 29, 2015 14:18
-
-
Save doronkatz/321b5950939850ae6b6f to your computer and use it in GitHub Desktop.
Swift and __nullable and _nonnull
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Pet { | |
func assignOwnerForCat(cat: Cat!, withSerial serial: Int!) | |
} | |
... | |
func serialAssignmentForCat(cat: Cat, forSerial serial: Int?) { | |
var snuggles = Pet() | |
snuggles.assignOwnerForCat(cat, withSerial: serial) | |
} | |
... | |
class PFObject { | |
func setObject(object: AnyObject, forKey key: String) | |
} | |
func createObjectWithName(name: String, forKey key: String?) { | |
let object = PFObject(className: "Object") | |
object.setObject(name, forKey: key) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface Pet: NSObject{ | |
-(void)assignOwnerForCat(NON_NULL id)cat withSerial:(NON_NULL NSNumber*)serial; | |
} | |
@end | |
@implementation Pet{ | |
- (void)serialAssignmentForCat:(Cat *)cat forSerial:(nullable NSNumber *)erial | |
... | |
[pet assignOwnerForCat:cat forSerial:serial]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment