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

MKMapView support #103

Open
igorkulman opened this issue Apr 2, 2020 · 0 comments
Open

MKMapView support #103

igorkulman opened this issue Apr 2, 2020 · 0 comments

Comments

@igorkulman
Copy link
Contributor

This library is obviously concentrated on UITableView and UICollectionView support but MKMapView has a lot of the same concepts: registering annotations and dequeuing them.

I currently use a simple extension for that

extension MKMapView {
    final func register<T: MKAnnotationView>(annotationType: T.Type)
      where T: Reusable {
        self.register(annotationType.self, forAnnotationViewWithReuseIdentifier: annotationType.reuseIdentifier)
    }

    final func dequeueReusableAnnotation<T: MKAnnotationView>(annotationType: T.Type = T.self) -> T
    where T: Reusable {
        guard let view = self.dequeueReusableAnnotationView(withIdentifier: annotationType.reuseIdentifier) as? T else {
          fatalError(
            "Failed to dequeue a annotation view with identifier \(annotationType.reuseIdentifier) matching type \(annotationType.self). "
              + "Check that the reuseIdentifier is set properly in your XIB/Storyboard "
              + "and that you registered the annotation view beforehand"
          )
        }
        return view
    }
}

I wonder if you be willing to add MKMapView support. I can provide this extension as a PR together with some documentation and maybe even a sample.

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

1 participant