Skip to content

Commit 2dd3b13

Browse files
author
iBinh
committed
update delegate
1 parent 9b0566e commit 2dd3b13

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

GoongGeocoder.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Pod::Spec.new do |s|
33
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
44

55
s.name = "GoongGeocoder"
6-
s.version = "0.0.4"
6+
s.version = "0.0.5"
77
s.summary = "Goong Geocoding, Autocomplete API for Swift and Objective C"
88

99
s.description = <<-DESC

GoongGeocoder/GoongAutocompleteViewController.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import UIKit
22

33
@objc public protocol GoongAutocompleteDelegate {
4-
@objc func didSelectPlacemark(_ placemark: Placemark?)
4+
@objc func viewController(_ viewController: GoongAutocompleteViewController, didAutocompleteWith place: Placemark?)
5+
@objc func viewController(_ viewController: GoongAutocompleteViewController, didFailAutocompleteWithError error: Error?)
56
}
67
@objc open class GoongAutocompleteViewController: UIViewController {
78
var tableView: UITableView!
@@ -156,12 +157,20 @@ extension GoongAutocompleteViewController: UITableViewDelegate, UITableViewDataS
156157
func fetchPlaceID(_ placeID: String) {
157158
geocoder.fetchPlace(from: placeID) { (result, err) in
158159
if let err = err {
159-
print(err.localizedDescription)
160+
self.dismiss(animated: true) {
161+
self.delegate?.viewController(self, didFailAutocompleteWithError: err)
162+
}
160163
}
161164
guard let result = result else {
165+
self.dismiss(animated: true) {
166+
self.delegate?.viewController(self, didFailAutocompleteWithError: nil)
167+
}
162168
return
163169
}
164-
self.delegate?.didSelectPlacemark(result.placemark)
170+
self.dismiss(animated: true) {
171+
self.delegate?.viewController(self, didAutocompleteWith: result.placemark)
172+
}
173+
165174
}
166175
}
167176
@objc func handleSectionTap(gesture: UITapGestureRecognizer) {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GoongGeocoder makes it easy to connect your iOS application to the [Goong Geocod
1414
Specify the following dependency in your [CocoaPods](http://cocoapods.org/) Podfile:
1515

1616
```podspec
17-
pod 'GoongGeocoder', '~> 0.0.2'
17+
pod 'GoongGeocoder'
1818
```
1919

2020
Then `import GoongGeocoder` or `@import GoongGeocoder;`.
@@ -161,4 +161,4 @@ geocoder.fetchPlace(from: <#Place ID#>) { (<#PlaceDetailResult?#>, <#NSError?#>)
161161
[geocoder fetchPlace:@"" completionHandler:^(PlaceDetailResult * _Nullable result, NSError * _Nullable err) {
162162
<#code#>
163163
}]
164-
```
164+
```

0 commit comments

Comments
 (0)