他にも学校のクラスをテーブルビューに読み込むアプリを実行しようとしています。コードはそれは私にエラーを返し実行されると私はCloudKitのレコードを保存できません、なぜですか?
import UIKit
import CloudKit
class AddPostVC: UIViewController {
@IBOutlet weak var postText: UITextView!
let database = DatabaseController()
override func viewDidLoad() {
super.viewDidLoad()
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIInputViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
}
//Calls this function when the tap is recognized.
func dismissKeyboard() {
//Causes the view (or one of its embedded text fields) to resign the first responder status.
view.endEditing(true)
}
@IBAction func postButtonPressed() {
let newPost = Post()
newPost.text = postText.text
newPost.user = CKReference(recordID: CKRecordID(recordName: UserDefaults.standard.string(forKey: "userRecordID")!), action: CKReferenceAction.none)
newPost.save() { _, error in
if error == nil {
DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
}
} else {
if !self.database.networkCheck() {
DispatchQueue.main.async {
self.displayErrorMessage(message: "It seems that there is no internet connection, try again")
}
} else {
DispatchQueue.main.async {
self.displayErrorMessage(message: error.debugDescription + ". Contact Apple or us for help")
}
}
}
}
}
func displayErrorMessage(message:String) {
let alert = UIAlertController(title: "Error", message: message, preferredStyle: .alert)
let dismissAction = UIAlertAction(title: "Dismiss", style: .default, handler: nil)
alert.addAction(dismissAction)
self.present(alert, animated: true)
}
}
:
[LogFacilityCK] Got a connection error for operation 69CB31B15036D50D: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.cloudd" UserInfo={NSDebugDescription=connection to service named com.apple.cloudd}
は、この問題を解決する方法を誰もが知っていたコードは次のようになりますか?私はまだインターネット上のsolutiosnを見つけることができません。
あなた自身の質問に答えることとそれを回答として掲示するのは素晴らしい仕事です。 – MwcsMac
本当に役に立ちます。ダニーに感謝します。 – EmptyStack