CoreData를 사용하여 사용자가 자동 완성 위젯을 사용하여 Google지도에 마크하는 마커를 저장하고 검색하려고합니다. 그러나 계속 'libC++ abi.dylib : NSException 유형의 잡히지 않은 예외로 종료'오류가 발생하고 이것이 의미하는 바가 무엇인지 또는 확실하지 않습니까? 내가 코어 데이터에 객체를 저장하려고 할 때 발생합니다.코어 데이터에 Google 장소 개체 저장 - NSException 유형의 캐치되지 않은 예외로 종료
다음은 관련 코드입니다 :
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
self.place = place
let camera = GMSCameraPosition.camera(withLatitude: place.coordinate.latitude, longitude: place.coordinate.longitude, zoom: 15.0)
self.vwGMap.camera = camera
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(place.coordinate.latitude, place.coordinate.longitude)
marker.title = place.name
marker.snippet = place.formattedAddress
marker.map = self.vwGMap
marker.icon = GMSMarker.markerImage(with: UIColor.blue)
marker.tracksViewChanges = true
self.dismiss(animated: true, completion: nil)
print("Place name: ", place.name)
print("Place address: ", place.formattedAddress)
print("Place placeID: ", place.placeID)
print("Place attributions: ", place.attributions)
print("Place Coordinate:", place.coordinate)
//The printing only happens in the terminal
let newPlaceName = place.name
self.newPlaceName = place.name
let newPlaceAddress = place.formattedAddress
self.newPlaceAddress = place.formattedAddress!
let newPlacePlaceID = place.placeID
self.newPlacePlaceID = place.placeID
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let context = appDelegate.persistentContainer.viewContext
let newPlace = NSEntityDescription.insertNewObject(forEntityName: "StoredPlace", into: context)
newPlace.setValue(newPlaceName, forKeyPath: "name")
newPlace.setValue(newPlaceAddress, forKeyPath: "address")
newPlace.setValue(newPlacePlaceID
, forKeyPath: "placeID")
do
{
try context.save()
print("SAVED")
}
catch
{
//PROCESS ERROR
}
}
아마도 내가있는 viewDidLoad에 송출 AppDelegate에 등을 넣어해야하지만 같은 치명적인 오류가 결국.
StoredPlace 엔터티에 'String'유형의 속성으로 name, address, placeID가 설정된 속성이 있습니다. 때문에 캐치되지 않는 예외 'NSInvalidArgumentException', 이유에 종단 응용 프로그램 :
오류에 대한 자세한 내용을 '+ entityForName : 전무는 엔티티 이름을 검색 법적 NSManagedObjectContext 매개 변수 아니다'StoredPlace '' *** 먼저 던져 호출 스택 :
이 오류는 무엇을 의미하며 어떻게 처리합니까?
이것은 ViewController입니다. 게시물을 업데이트하여 AppDelegate 메소드를 표시합니다. 나는 최신 버전의 Xcode와 Swift를 사용하고있다. –
오, 이런, 물어 봤기 때문에, xcdatamodel과 일치하는 컨테이너 이름을 바꾸는 것을 잊어 버린 것에 대해 감사한다. –