terryworona / TWMessageBarManager

An iOS manager for presenting system-wide notifications via a dropdown message bar.
MIT License
1.77k stars 191 forks source link

Add nullability annotations to better support Swift. #83

Closed rexeisen closed 8 years ago

rexeisen commented 9 years ago
terryworona commented 9 years ago

Is the nullable annotation not the default behavior when using ObjC from Swift?

From what I can see, only the nonnullable annotations would be required, no?

rexeisen commented 9 years ago

It's actually null_unspecified which makes everything come through as having bangs (!) on it.

So the API changes from looking like

public func showMessageWithTitle(title: String!, 
    description: String!, 
    type: TWMessageBarMessageType, 
    duration: CGFloat, 
    statusBarHidden: Bool, 
    callback: (() -> Void)!)

To

public func showMessageWithTitle(title: String?, 
    description: String?, 
    type: TWMessageBarMessageType, 
    duration: CGFloat, 
    statusBarHidden: Bool, 
    callback: (() -> Void)?)

Then we know that we can optionally specify the title, description, and callback. The reason that I made the PR is that I ended up having to look through the library to make sure it was ok to pass nil as the completion block.