Ich habe meine App kürzlich auf swift 3 aktualisiert und stürzte immer dann ab, wenn versucht wurde, den Autocomplete-View-Controller in Google Maps aufzurufen. Ich weiß, dass ein API-Schlüssel nicht das Problem ist, weil es gut funktionierte, als ich es benutzte, bevor ich auf Swift 3 und Xcode 8 umstieg. Ich weiß das auch, weil die App immer noch in der Lage ist, eine Google Map anzuzeigen. Hier ist mein Code:GMSAutoCompleteViewController Absturz - Swift 3
extension AdditionalSetupViewController: GMSAutocompleteViewControllerDelegate {
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
let locationCoordinate = place.coordinate
if homeClicked {
homeAddress = [locationCoordinate.latitude, locationCoordinate.longitude]
}
else if homeAddress == [] {
}
else {
let coordString = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".replacingOccurrences(of: ".", with: ",")
// let coordString = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".stringByReplacingOccurrencesOfString(".", withString: ",")
ref = FIRDatabase.database().reference()
let currentUser: String = (FIRAuth.auth()?.currentUser?.uid)!
let address = ref.child("schoolOrWorkAddress").child(coordString)
let childUpdates = [currentUser: homeAddress]
address.updateChildValues(childUpdates)
finishButton.alpha = 1
finishButton.isEnabled = true
}
let schoolorWorkCoords = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".replacingOccurrences(of: ".", with: ",")
// let schoolorWorkCoords = "\(locationCoordinate.latitude) \(locationCoordinate.longitude)".stringByReplacingOccurrencesOfString(".", withString: ",")
let userID = (FIRAuth.auth()?.currentUser?.uid)!
_ = ref.child("posts").child(userID).key
let additionalBasicInfo = ["schoolOrWorkAddress": schoolorWorkCoords, "homeAddress": homeAddress] as [String : Any]
let usersRef = ref.child("users/\(userID)")
usersRef.updateChildValues(additionalBasicInfo as [NSObject : AnyObject])
self.dismiss(animated: true, completion: nil)
}
func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: Error) {
print(error)
}
func wasCancelled(_ viewController: GMSAutocompleteViewController) {
self.dismiss(animated: true, completion: nil)
}
func didRequestAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}
func didUpdateAutocompletePredictions(_ viewController: GMSAutocompleteViewController) {
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}
}
Hier ist der Fehlerausgang:
[Pars2.AdditionalSetupViewController addYourSchoolOrWorkAddress:]: unrecognized selector sent to instance 0x7fc4c8d7f200
2016-11-12 13:55:31.755 Pars2[3065:191093] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Pars2.AdditionalSetupViewController addYourSchoolOrWorkAddress:]: unrecognized selector sent to instance 0x7fc4c8d7f200'
*** First throw call stack:
(
0 CoreFoundation 0x00000001068f534b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010635621e objc_exception_throw + 48
2 CoreFoundation 0x0000000106964f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010687ac15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010687a798 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000104b095b8 -[UIApplication sendAction:to:from:forEvent:] + 83
6 UIKit 0x0000000104c8eedd -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0000000104c8f1f6 -[UIControl _sendActionsForEvents:withEvent:] + 444
8 UIKit 0x0000000104c8e0f2 -[UIControl touchesEnded:withEvent:] + 668
9 UIKit 0x0000000104b76ce1 -[UIWindow _sendTouchesForEvent:] + 2747
10 UIKit 0x0000000104b783cf -[UIWindow sendEvent:] + 4011
11 UIKit 0x0000000104b2563f -[UIApplication sendEvent:] + 371
12 UIKit 0x000000010531771d __dispatchPreprocessedEventFromEventQueue + 3248
13 UIKit 0x00000001053103c7 __handleEventQueue + 4879
14 CoreFoundation 0x000000010689a311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x000000010687f59c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x000000010687ea86 __CFRunLoopRun + 918
17 CoreFoundation 0x000000010687e494 CFRunLoopRunSpecific + 420
18 GraphicsServices 0x0000000108f02a6f GSEventRunModal + 161
19 UIKit 0x0000000104b07964 UIApplicationMain + 159
20 Pars2 0x00000001010a078f main + 111
21 libdyld.dylib 0x00000001078d468d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
ich nicht, ob dies helfen könnte, aber hier ist der Code für den Rest meines View-Controller auch:
Ich habe keine Ahnung, warum es abstürzt, wenn es das nennt, aber jede Hilfe würde geschätzt werden!