Get list of folder and files within Assets.xcassets

前端 未结 1 1432
走了就别回头了
走了就别回头了 2021-01-20 13:40

I have 2 questions:

  1. I\'m adding large amount of mp3 files into Assets.xcassets, is there any performance issue with this?

  2. Within Assets.xcas

相关标签:
1条回答
  • 2021-01-20 14:27
    1. No it will not hamper your performance. If you face issue with loading large or many files, see this-Is it possible to load a compressed audio file directly into a buffer, without conversion?

    2. Get all folder and subfolder.

    For Obj c:

        NSArray *mainpaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,   NSUserDomainMask, YES);
    NSString *documentsDir = [mainpaths objectAtIndex:0];
    
    NSFileManager *Filemanager = [NSFileManager defaultManager];
    NSArray *fileList = [Filemanager contentsOfDirectoryAtPath:documentsDir error:nil];
    for (NSString *s in fileList){
        NSLog(@"YOu subfolder--%@", s);
    }
    

    For swift:

        let documentsDirectory =  try! NSFileManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
    let fileEnumerator = NSFileManager.defaultManager().enumeratorAtURL(documentsDirectory, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions(), errorHandler: nil)
    while let file = fileEnumerator?.nextObject() {
       //get all file name here.
    }
    
    0 讨论(0)
提交回复
热议问题