This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Returns Array from optional NSSet. Returns empty array if NSSet is nil. | |
* It's useful for when you want an Array of objects from a Core Data many relationship. | |
* | |
* Example usage with managed object `game` with 1-to-many relationship to `Goal` entity: | |
* let goalArray = game.goals.array(of: Goal.self) | |
*/ | |
extension Optional where Wrapped == NSSet { | |
func array<T: Hashable>(of: T.Type) -> [T] { |