使用addObjectsFromArray从NSMutableArray中检索值

时间:2012-11-27 11:54:17

标签: ios6 nsmutablearray nsdictionary

BookmarksPlist是一个NSMutableArray,它作为Dictionary存储在Plist文件中。以下代码......

bookmarks = [[NSMutableArray alloc] init];
NSLog(@"BOOKMARKPLIST ----==== %@", BookmarksPlist);
[bookmarks addObjectsFromArray:BookmarksPlist];
NSLog(@"BOOKMARK ----==== %@", bookmarks);

...生产:

2012-11-27 11:34:33.592 BOOKMARKPLIST ----==== {
    01Otabkey14tabkey1 = "Genesis 14";
    01Otabkey8tabkey1 = "Genesis 8";
    01Otabkey9tabkey1 = "Genesis 9";
}
2012-11-27 11:34:33.592 *** -[NSMutableArray addObjectsFromArray:]: array argument is not an NSArray
2012-11-27 11:34:33.593 BOOKMARK ----==== (
    01Otabkey8tabkey1,
    01Otabkey9tabkey1,
    01Otabkey14tabkey1
)

所以问题是如何让书签数组获取BookmarksPlist数组的值而不是键?所以它看起来像这样:

2012-11-27 11:34:33.593 BOOKMARK ----==== (
    "Genesis 14",
    "Genesis 8",
    "Genesis 9"
)

1 个答案:

答案 0 :(得分:1)

BookmarksPlist可能是字典。您可以使用allKeys的字典和allValues的值来获取密钥。