animation - SceneKit Swift3 compiler-error -


i'm trying run animated "dae" model in scenekit:

let url = bundle.main.url(forresource: "art.scnassets/player(walking)", withextension: "dae")     let scenesource = scnscenesource(url: url!, options: [scnscenesource.loadingoption.animationimportpolicy: scnscenesource.animationimportpolicy.playrepeatedly] )     let animationids: nsarray = scenesource?.identifiersofentries(withclass: caanimation)      eachid in animationids {         let animation: caanimation = (scenesource?.entrywithidentifier(eachid as! string, withclass: caanimation.self))!         animations.add(animation)     }     character?._walkanimations = animations 

but compiler throws on line:

let animationids: nsarray = scenesource?.identifiersofentries(withclass: caanimation)

and writes error:

cannot convert value of type '[string]?' specified type 'nsarray'

please me fix problem.

thanks in advance.

why converting [string]? nsarray , convert each element string again, no need of use swift native array , wrapped optional value if let or guard let.

guard let animationids = scenesource?.identifiersofentries(withclass: caanimation) else {     return } eachid in animationids {     if let animation = scenesource?.entrywithidentifier(eachid, withclass: caanimation.self) {         animations.add(animation)     } } character?._walkanimations = animations 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -