The code that was in this package has been moved into w3w-swift-components.
It is enclosed in a compile time conditional so that it will be included if the What3Words SDK is present, otherwise it will not compile into the project.
You may safely remove this package as a dependancy from your project, and add w3w-swift-components in it's place if it's not already there.
what3words publishes a compoonents library on GitHub. Out of the box, it is designed to work with the what3words API.
However, this package will extend the functionality of the Swift SDK so that it can use those components too.
Include this in your project, and it will provide some protocol extensions and cause the download of the compoonents library into your project because it is a dependancy of this package.
W3WAutoSuggestTextField
is a UITextField
that will suggest three word addresses as the user types.
Documentation for W3WAutoSuggestTextField
as well as other components you may use can be found in the components library.
Include w3w.xcframework
in your Xcode project as per the readme.txt
in the SDK package you recieved from what3words.
Add this Swift Package to your project:
Add the import statements to your ViewController's code:
import w3w
import W3WSwiftComponents
import W3WSwiftComponentsSdk
Place this code in your ViewController's viewDidLoad()
:
override func viewDidLoad() {
super.viewDidLoad()
// the SDK
let sdk = What3Words()
// make the text field
let textField = W3WAutoSuggestTextField(frame: CGRect(x: 16.0, y: 64.0, width: view.frame.size.width - 32.0, height: 32.0))
// assign the SDK to it
textField.set(sdk)
// assign a code block to execute when the user has selected an address
textField.suggestionSelected = { suggestion in
print(suggestion.words ?? "")
}
// the error can be captured using onError
textField.onError = { error in
print(String(describing: error))
}
// place in the view
view.addSubview(textField)
}
This code is the same that you would use for the API, the only difference is the passing the SDK instead of the API to the component. Eg: textField.set(What3Words())
instead of textField.set(What3WordsV3(apiKey: "YourApiKey"))
Take a look at the compoonents library to see the other components available for use.
what3words' SDK is a self contained framework of Swift code for 3 word addresses functionality.
W3WSdk
, for example, W3WSdkSuggestion
, W3WSdkOption
, etc...W3WApi
, such as W3WApiSuggestion
and W3WApiSquare
.W3WSuggestion
, W3WOption
, W3WSquare
, etc...This package contains SdkToApiBridge.swift which makes the classes in the SDK conform to these "main" protocols.
Most importantly, all the component code uses only the "main" protocols and this allows both the API and the SDK to employ it.
link |
Stars: 0 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics