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

Use Swift's protocol extensions to remove the id for the view / layout guide #48

Open
orta opened this issue Apr 18, 2016 · 0 comments
Open

Comments

@orta
Copy link
Collaborator

orta commented Apr 18, 2016

Currently the API is:

- (NSArray <NSLayoutConstraint *> *)alignToView:(id)view;

This id isn't optimal. With Swift we could do something like:

@objc protocol FLKViewable {
  var flkView: UIView { get }
}

extension UIView: FLKViewable {
  var flkView: UIView  {
    return self
  }
}
extension UILayoutGuide: FLKViewable {
  var flkView: UIView  {
    return self.representedView
  }
}
extension FLKLayoutGuide: FLKViewable {
  var flkView: UIView  {
    return self.flk_view
  }
}

Then we could constrain the view to be a FLKViewable:

- (NSArray <NSLayoutConstraint *> *)alignToView:(NSObject <FLKViewable> *)view;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant