1

How does one convert a 2D array to an array of sets in Swift, without using NSArray or NSSet?

I would like to go from [[UIView]] to var convertedSetsArray: [Set<UIView>]

1 Answer 1

3

Use something like this (assuming that views is an array of array of UIViews):

let result = views.map { Set($0) }

the type of views is [[UIView]], the result is Array<Set<UIView>>, so you didn't use any "NS" related types.

Sign up to request clarification or add additional context in comments.

1 Comment

I have an array of UIView arrays

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.