Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement nullable / nonnull attributes on parameters and properties #73

Closed
joeljfischer opened this issue Feb 9, 2015 · 1 comment
Closed
Milestone

Comments

@joeljfischer
Copy link
Contributor

Xcode 6.3 introduces attributes for parameters and properties that indicate nullability, mainly for Swift interop (EDIT: Also for Obj-C interactions!). We'll want to implement that into our APIs to help any Swift developers out there.

 #pragma clang assume_nonnull begin
     // ...
     -(void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString
*)identifier;
-(nullable UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath)indexPath;
@property (nonatomic, readwrite, retain, nullable) UIView *backgroundView; // ...
#pragma clang assume_nonnull end

Adding nullability annotations to Objective-C APIs does not affect backward compatibility or the way in which the compiler generates code. For example, nonnull pointers can still end up being nil in some cases, such as when messaging a nil receiver. However, nullability annotations—in addition to improving the experience in Swift—provide new warnings in Objective-C if, for example, a nil argument is passed to a nonnull parameter, making Objective-C APIs more expressive and easier to use correctly.

@joeljfischer joeljfischer changed the title [Future] Implement nullable / nonnull attributes on parameters and properties Implement nullable / nonnull attributes on parameters and properties Apr 10, 2015
@joeljfischer joeljfischer added this to the 4.1.0 milestone Apr 10, 2015
@joeljfischer joeljfischer modified the milestones: 5.0.0, 4.X Jul 29, 2016
@asm09fsu
Copy link
Contributor

Merged into develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants