NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"BDNovelChannel" ofType:@"txt"];
NSData *data = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&error];
本文介绍了一种使用Swift语言从NSBundle加载本地TXT文件的方法。通过示例代码展示了如何获取资源路径,并利用NSData读取文件内容。
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"BDNovelChannel" ofType:@"txt"];
NSData *data = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&error];
6284
248

被折叠的 条评论
为什么被折叠?