寻找使用Objective-C(以及Swift作为第二个偏好)解决此问题的最有效方法。
您有一个包含以下集合的nsdictionary。
NSDictionary dict = @{
{ @"foo", [NSNumber numberWithInt:1] },
{ @"bar", [NSNumber numberWithInt:10] },
{ @"baz", [NSNumber numberWithInt:11] },
{ @"boz", [NSNumber numberWithInt:1] },
};
我应该收到一个包含值的列表(1、10、11)。
提取值(作为数组,[dict allValues]
),然后将其胁迫到NSSet(initWithArray:
)。
,如果您确实想要一个数组,则可以随时胁迫回到数组;但是我一般发现,当他们真正需要的是首先需要的时,人们经常需要一个数组。