How to covert NSMutableOrderedSet to generic array?
问题 I have this for loop, p is a NSManagedObject , fathers is a to-many relationship, so I need to cast NSMutableOrderedSet to [Family] but it does not work, why? for f in p.fathers as [Family] { } 回答1: You can obtain an array representation of the set via the array property - then you can downcast it to the proper type and assign to a variable: let families = p.fathers.array as [Family] but of course you can also use it directly in the loop: for f in p.fathers.array as [Family] { .... } 回答2: The