Check that the contents of one NSArray are all in another array

前端 未结 9 1814
说谎
说谎 2020-12-10 08:28

I have one NSArray with names in string objects like this:@[@\"john\", @\"smith\", @\"alex\", @\"louis\"], and I have another array that contains

9条回答
  •  忘掉有多难
    2020-12-10 08:48

    NSSet has the functionality that you are looking for.

    If we disregard performance issues for a moment, then the following snippet will do what you need in a single line of code:

    BOOL isSubset = [[NSSet setWithArray: array1] isSubsetOfSet: [NSSet setWithArray: mainArray]];
    

提交回复
热议问题