簡體   English   中英

應用程序第一次打開時加載嘗試

[英]Loading trie first time the app opens

我正在使用自定義 ios 鍵盤。 對於單詞詞典,我已經實現了自動更正的嘗試。 Trie 也在目標 c 中編碼。 我有 10 萬個單詞表。 我只想在應用程序第一次打開時加載特里樹,它應該被永久存儲。 是否可以?

只加載一次,下載是什么意思?

鑒於您下載了數據(假設為來自 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];

有關歸檔對象的更多信息,請訪問: 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