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

Add nullability annotations to better support Swift. #83

Merged
merged 1 commit into from
Dec 7, 2015
Merged

Add nullability annotations to better support Swift. #83

merged 1 commit into from
Dec 7, 2015

Conversation

rexeisen
Copy link

  • Added nullability annotations to better support Swift projects.
  • Prefixed isRunningiOS7OrLater category to avoid any collisions
  • Removed default cases on switching on enum so if future enums are added, compiler will give some warnings. No warnings now since the switch is exhaustive.

- Prefixed category to avoid any collisions
- Removed default cases on switching on enum so if future enums are added, compiler will give some warnings. No warnings now since the switch is exhaustive.
@terryworona
Copy link
Owner

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
Copy link
Author

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.

terryworona added a commit that referenced this pull request Dec 7, 2015
Add nullability annotations to better support Swift.
@terryworona terryworona merged commit e0fdc31 into terryworona:master Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants