【问题标题】:Count Number of Files with Extension in iPhone Documents计算 iPhone 文档中带有扩展名的文件数
【发布时间】:2012-02-27 16:41:21
【问题描述】:

我可以想办法通过获取数组来做到这一点:

NSArray *doc_contents = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil];

并进行字符串解析以查找扩展名,但这似乎是一种迂回的方式。有没有一种简单明了的方法来计算我的 iPhone 应用程序文档目录中 .jpg 文件的数量?

谢谢。

编辑在这里解决:Creating an array from documentsDirectory includes ends with .MOV

【问题讨论】:

标签: iphone objective-c nsfilemanager


【解决方案1】:

这两个链接都是解决这个问题的好资源。

这个解决了当你有多个文件扩展名你正在寻找的情况:
NSPredicate endswith multiple files

这个只关注一个扩展:
Creating an array from documentsDirectory includes ends with .MOV

两种方法都使用 NSPredicate 类。

【讨论】:

    【解决方案2】:

    您应该查看名为“Xcode Statistician”的应用程序。它真的很干净,并且会告诉您如何处理大量其他信息,例如总行数等。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-14
      • 2010-11-22
      • 1970-01-01
      • 1970-01-01
      • 2010-12-28
      • 2011-08-18
      • 1970-01-01
      相关资源
      最近更新 更多