我想用4作为离线翻译(词典)。
我需要有关将单词存储在翻译中的建议。 现在,带有翻译的单词为dsl格式,我将搜索此特定文件,但平均需要2-3秒的搜索时间。
是否可以加快搜索速度?如果我在核心数据或领域数据库中添加了翻译后的单词,它的帮助与否?
答案 0 :(得分:0)
Realm Swift可让您以安全,持久和快速的方式有效地编写应用程序的模型层。外观如下:
// Define your models like regular Swift classes
class Dog: Object {
@objc dynamic var name = ""
@objc dynamic var age = 0
}
class Person: Object {
@objc dynamic var name = ""
@objc dynamic var picture: Data? = nil // optionals supported
let dogs = List<Dog>()
}
// Use them like regular Swift objects
let myDog = Dog()
myDog.name = "Rex"
myDog.age = 1
print("name of dog: \(myDog.name)")
// Get the default Realm
let realm = try! Realm()
// Query Realm for all dogs less than 2 years old
let puppies = realm.objects(Dog.self).filter("age < 2")
puppies.count // => 0 because no dogs have been added to the Realm yet
// Persist your data easily
try! realm.write {
realm.add(myDog)
}
// Queries are updated in realtime
puppies.count // => 1
// Query and update from any thread
DispatchQueue(label: "background").async {
autoreleasepool {
let realm = try! Realm()
let theDog = realm.objects(Dog.self).filter("age == 1").first
try! realm.write {
theDog!.age = 3
}
}
}
对于字典应用程序。我肯定会选择Realm。它使用NSFileProtection和加密技术,因此人们将无法窃取您的翻译数据。