How would I combine two arrays in Objective-C?

后端 未结 3 1340
自闭症患者
自闭症患者 2021-01-31 01:00

What is the Objective-C equivalent of the JavaScript concat() function?

Assuming that both objects are arrays, how would you combine them?

3条回答
  •  无人及你
    2021-01-31 01:57

    Here's a symmetric & simple way by just beginning with an empty array:

    NSArray* newArray = @[];
    newArray = [newArray arrayByAddingObjectsFromArray:firstArray];
    newArray = [newArray arrayByAddingObjectsFromArray:secondArray];
    

提交回复
热议问题