简体   繁体   English

应用程序第一次打开时加载尝试

[英]Loading trie first time the app opens

I am working on a custom ios keyboard.我正在使用自定义 ios 键盘。 For the dictionary of words, I have implemented trie for autocorrect.对于单词词典,我已经实现了自动更正的尝试。 Trie is coded in objective c as well. Trie 也在目标 c 中编码。 I have 100k wordlist.我有 10 万个单词表。 I want to load the trie only the first time the app opens and it should get stored permanently.我只想在应用程序第一次打开时加载特里树,它应该被永久存储。 Is it possible?是否可以?

What do you mean with loading only once, downloading?只加载一次,下载是什么意思?

Given that you download the data (let's assume as a txt from the internet) you can build up your trie and serialize that via NSKeyedArchiver and also restore it.鉴于您下载了数据(假设为来自 Internet 的 txt),您可以构建您的尝试并通过 NSKeyedArchiver 对其进行序列化并恢复它。

Trie *wordsTrie = [[Trie alloc]initWithUrl:@"https://www.internet.com/words.txt"]];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:wordsTrie];

/* persist the data ... */

Trie *restoredWordsTrie = [NSKeyedUnarchiver unarchiveObjectWithData:data];

More about archiving objects can be found here: https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Archiving.html有关归档对象的更多信息,请访问: https : //developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Archiving.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM