Haha, I am a newbie. The following describes how to view the file list in iOS development.
View the file list in the root directory
- NSArray *leveList=
- [[[NSFileManager alloc]init] contentsOfDirectoryAtPath: [NSHomeDirectory() stringByAppendingPathComponent:@""] error:nil];
- for (NSString *str in leveList) {
- NSLog(@"levelList:%@",str);
- }
- NSLog(@"count:%d",[leveList count] );
The results of the file list are as follows:
- 2013-06-14 16:18:14.513 helloword[853:c07] levelList:Documents
- 2013-06-14 16:18:14.533 helloword[853:c07] levelList:helloword.app
- 2013-06-14 16:18:14.534 helloword[853:c07] levelList:Library
- 2013-06-14 16:18:14.535 helloword[853:c07] levelList:tmp
- 2013-06-14 16:18:14.537 helloword[853:c07] count:4
View the Library file list
- NSArray *leveList=
- [[[NSFileManager alloc]init] contentsOfDirectoryAtPath: [NSHomeDirectory() stringByAppendingPathComponent:@"Library"] error:nil];
- for (NSString *str in leveList) {
- NSLog(@"Library:%@",str);
- }
- NSLog(@"count:%d",[leveList count] );
The result is as follows:
- 2013-06-14 16:26:49.475 helloword[1040:c07] Library:Caches
- 2013-06-14 16:26:49.478 helloword[1040:c07] Library:Preferences
- 2013-06-14 16:26:49.480 helloword[1040:c07] count:2