Convert NSArray to Swift Array

后端 未结 4 1694
终归单人心
终归单人心 2020-12-29 03:23

In CoreData I have defined an ordered to-many relationship. This relationship is defined in Swift like this:

@NSManaged var types : NSMutableArray
<         


        
4条回答
  •  爱一瞬间的悲伤
    2020-12-29 04:08

    The following is a working piece of code from one of my projects that might help?

    if let rawArray = rawData as? NSArray,
       let castArray = rawArray as? Array< Dictionary< String, AnyObject > >
       { 
           // etc... 
       }
    

    It works, although I'm not sure it would be considered optimal.

提交回复
热议问题