为了理解Kinvey文档,我编写了一个简单的应用程序,将对象"book“保存在集合"Book”中。
不幸的是,我收到以下错误
dyld_sim`dyld_fatal_error:我的代码如下
AppDelegate
import UIKit
import Kinvey
import SVProgressHUD
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
lazy var fileStore: FileStore = {
return FileStore.getInstance()
}()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Kinvey.sharedClient.initialize(
appKey: "kid_rJngK8I_x",
appSecret: "6439a2ee96ef412083f10108666f6004"
)
if let _ = Kinvey.sharedClient.activeUser {
//do nothing
} else {
SVProgressHUD.show()
User.exists(username: "test") { exists, error in
if exists {
User.login(username: "test", password: "test") { user, error in
SVProgressHUD.dismiss()
if let _ = user {
//do nothing
} else {
//do something!
}
}
} else {
User.signup(username: "test", password: "test") { user, error in
SVProgressHUD.dismiss()
if let _ = user {
//do nothing
} else {
//do something!
}
}
}
}
}
return true
}Book.swift
import Foundation
import Kinvey
class Book: Entity {
dynamic var title: String?
dynamic var authorName: String?
override class func collectionName() -> String {
//return the name of the backend collection corresponding to this entity
return "Book"
}
//Map properties in your backend collection to the members of this entity
override func propertyMapping(_ map: Map) {
//This maps the "_id", "_kmd" and "_acl" properties
super.propertyMapping(map)
//Each property in your entity should be mapped using the following scheme:
//<member variable> <- ("<backend property>", map["<backend property>"])
title <- ("title", map["title"])
authorName <- ("authorName", map["author"])
}
}ViewController
import UIKit
import Kinvey
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let dataStore = DataStore<Book>.collection()
let book = Book()
book.title = "Steal This Book"
book.authorName = "Abbey Hoffman"
print("Abbey Hoffman")
dataStore.save(book) { book, error in
if let book = book {
//succeed
print("Book: \(book)")
} else {
//fail
}// close else
} //closesave block
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}当我从ViewController.swift中注释掉以下代码时,我的代码运行起来没有任何问题
dataStore.save(book) { book, error in
if let book = book {
//succeed
print("Book: \(book)")
} else {
//fail
}// close else
} //closesave block在备份上生成新用户,但不会向图书集合中添加任何内容
下面是我的调试器窗口的屏幕快照

发布于 2017-02-09 21:44:13
布莱恩
看看是否可以使用Clean & Build (或者重新启动Xcode)来解决这个问题。您还可以考虑从~/Library/Developer/Xcode/DerivedData中删除相关文件夹。
为我提供你得到的错误的屏幕截图。如果你能为我提供样本项目,在那里你看到的错误,将是很大的。
另外,您使用的是什么版本的SDK?
谢谢,Pranav Kinvey支持
https://stackoverflow.com/questions/42126656
复制相似问题