Skip to content

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

@orta

Description

@orta

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;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions