だから私はこれをテストしようとしています。基本的に、rawData.txt という名前のテキスト ファイルが含まれています。次のようになります。
060315512 Name Lastname
050273616 Name LastName
行を分割してから、個々の行を分割して最初の部分 (9 桁) を確認したかったのですが、まったく機能していないようです (ウィンドウが閉じます) このコードに問題はありますか?
NSString *path = [[NSBundle mainBundle] pathForResource: @"rawData" ofType:@"txt"];
if (path)
{
NSString *textFile = [NSString stringWithContentsOfFile:path];
NSArray *lines = [textFile componentsSeparatedByString:(@"\n")];
NSArray *line;
int i = 0;
while (i < [lines count])
{
line = [[lines objectAtIndex:i] componentsSeparatedByString:(@" ")];
if ([[line objectAtIndex:0] stringValue] == @"060315512")
{
idText.text = [[line objectAtIndex: 0] stringValue];
}
i++;
}
}