解析する 2 行の文字列は次のとおりです。
00:02.0 VGA compatible controller [0300]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2772] (rev 02)
00:02.1 Display controller [0380]: Intel Corporation 82945G/GZ Integrated Graphics Controller [8086:2776] (rev 02)
これらの文字列を取り出すには:
(1行目から)
- VGA対応コントローラー
- Intel Corporation 82945G/GZ 統合グラフィックス コントローラ
- [8086:2772]
(2行目から)
- ディスプレイコントローラー
- Intel Corporation 82945G/GZ 統合グラフィックス コントローラ
- [8086:2776]
今私の開始コードは次のとおりです。
NSScanner *scn = [NSScanner scannerWithString:strtoparse];
NSString *devtype;
while ([scn isAtEnd] == NO)
{
if( [scn scanUpToCharactersFromSet:[NSCharacterSet whitespaceCharacterSet] intoString:NULL] &&
[scn scanUpToString:@"[" intoString:&devtype]);
}
そして、これは機能していません。ドキュメントからスキャナーを理解することさえできません。では、誰かが作業コードを投稿できますか?