iOS 本地化搜尋歷史或純文字訊息
阿新 • • 發佈:2019-01-25
路徑:NSString *parh = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"searchHistory.plist"];
獲取:NSMutableArray *searchHistories = [NSKeyedUnarchiver unarchiveObjectWithFile:parh];
插入某條:[searchHistories removeObject:@"historyText"];
[searchHistories insertObject:@"historyText" atIndex:0];
[NSKeyedArchiver archiveRootObject:searchHistories toFile:parh];
刪除某條:[searchHistories removeObject:@"historyText"];
[NSKeyedArchiver archiveRootObject:searchHistories toFile:parh];
清空:[searchHistories removeAllObjects];
[NSKeyedArchiver archiveRootObject:searchHistories toFile:parh];