【问题标题】:Read Mutable Array from File / Plist从文件/Plist 中读取可变数组
【发布时间】:2013-07-16 14:55:21
【问题描述】:

这是我的问题。我使用 UISearchBar 在 UITableView 中显示来自 MutableArray 的文件。

所以我做了一个数组:

allTableData = [[NSMutableArray alloc] initWithObjects:
               [[CRFParts alloc] initWithName:@"ABC" andDescription:@"DEF"],
               [[CRFParts alloc] initWithName:@"GHI" andDescription:@"JKL"],
                nil];

我有大约 2000 行这样的内容。我从一个 excel 文件中构建了简单的字符串,但我的 .m 中的代码比它大。是否有可能从文件(plist/txt)中读取这些内容?

感谢您的帮助!

【问题讨论】:

  • 是的,你可以。有很多读取 plist 文件的示例...

标签: ios nsmutablearray nsarray


【解决方案1】:

尝试查看This Question。它有很多关于如何读取 plist 和字典 vs 数组的好代码。

下一次,在你问之前先搜索一下。

【讨论】:

    【解决方案2】:

    您可以轻松使用:
    NSArray *array = [[NSArray alloc] initWithContentsOfURL:url];
    NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfURL:url];

    查看Apple Documentation 的主题。
    请注意作为 plist 可以表示的结构以及在其根目录下的数组或字典。 Other thread关于它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-23
      • 2012-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多