I have the following text file structure (the text file is quite large, about 100,000 lines):
A|a1|111|111|111 B|111|111|111|111 A|a2|222|222|222 B|222|222|222|222 B|222|222|222|222 A|a3|333|333|333 B|333|333|333|333 ...
I need to extract a piece of text associated with this key. For example, if my key is A | a2, I need to save the following as a string:
A|a2|222|222|222 B|222|222|222|222 B|222|222|222|222
For my C ++ and Objective-C projects, I used the C ++ getline function as follows:
std::ifstream ifs(dataPathStr.c_str()); NSString* searchKey = @"A|a2"; std::string search_string ([searchKey cStringUsingEncoding:NSUTF8StringEncoding]);
As I make a project in Swift, I try to get rid of getline and replace it with something like βCocoaishβ. But I can not find a good Swift solution to solve the above problem. If you have an idea, I would really appreciate it. Thanks!
source share