如果您将扩展名更改为.txt
(当然将其保存为纯文本),您可以阅读它们。
当您将数字放在另一个下时,我为这种情况编写了一些代码
1234
2344
2345
这是我正在使用的代码。
NSString *title = @"test";
NSString *type = @"txt";
NSString *file = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:title ofType:type] encoding:NSUTF8StringEncoding error:nil];
NSArray *numberList = [[file stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]componentsSeparatedByString:@"\n"];
NSMutableArray *test4 = [[NSMutableArray alloc] init];
int lastItem = 0;
for (NSString *listItem in numberList)
{
//this is added because you most surely have a \n as last item and it will convert to 0
if(lastItem < listItem.count - 1)
[test4 addObject:[NSNumber numberWithInt:listItem.integerValue]];
lastItem++;
}