Ios8 scenekit类问题与xcode 6的更新

Ios8 scenekit类问题与xcode 6的更新,ios8,xcode6,scenekit,Ios8,Xcode6,Scenekit,我知道这个问题在新的更新中可能有点常见,也很可能是一个简单的解决方案,但我最近从xcode-6 beta升级到了完整版本,我的许多子类都有错误。我使用的是一个预先编程的scenekit 3d旋转地球仪,它与测试版配合得很好……我现在的构建失败,这给了我一个swift编译器错误:“SCNMatary?”没有一个名为“此处的多个子类”的成员 我在这里迷路了,所以任何帮助或指导都将不胜感激…谢谢 我正在使用的Github的源代码: 此外,下面是我的文件中的代码(与上面的Github文件相同) 您在Gi

我知道这个问题在新的更新中可能有点常见,也很可能是一个简单的解决方案,但我最近从xcode-6 beta升级到了完整版本,我的许多子类都有错误。我使用的是一个预先编程的scenekit 3d旋转地球仪,它与测试版配合得很好……我现在的构建失败,这给了我一个swift编译器错误:“SCNMatary?”没有一个名为“此处的多个子类”的成员

我在这里迷路了,所以任何帮助或指导都将不胜感激…谢谢

我正在使用的Github的源代码: 此外,下面是我的文件中的代码(与上面的Github文件相同)


您在GitHub上看到的示例很旧,并且由于框架已经开始适应Swift,因此没有保持最新。您看到的大多数错误都是因为场景工具包API已更新,以便在可能返回
nil
的情况下返回Optionals

比如说

lightNode.light.type = SCNLightTypeOmni
应改为

lightNode.light?.type = SCNLightTypeOmni

还有其他非常类似的情况,API已更新以返回可选项,例如:

theGlobeGeometry.firstMaterial.diffuse.contents = UIImage(named:"earth_diffuse.jpg")
theGlobeGeometry.firstMaterial.ambient.contents = UIImage(named:"earth_ambient2.jpeg")
theGlobeGeometry.firstMaterial.specular.contents = UIImage(named:"earth_specular.jpg")
// etc...
应该改成

theGlobeGeometry.firstMaterial?.diffuse.contents = UIImage(named:"earth_diffuse.jpg")
theGlobeGeometry.firstMaterial?.ambient.contents = UIImage(named:"earth_ambient2.jpeg")
theGlobeGeometry.firstMaterial?.specular.contents = UIImage(named:"earth_specular.jpg")
// etc...

请注意,在firstMaterial之后添加了
,因为不能保证几何体对象具有材质。

我注意到还有一件事可能是类似的修复,但我得到了这个错误…“[AnyObject]?”没有名为“subscript”的成员用于检索第一个单击的对象…//如果hitResults?.count>0{//检索到第一个单击的对象,请检查我们是否至少单击了一个对象。let result:AnyObject!=hitResults[0]
theGlobeGeometry.firstMaterial.diffuse.contents = UIImage(named:"earth_diffuse.jpg")
theGlobeGeometry.firstMaterial.ambient.contents = UIImage(named:"earth_ambient2.jpeg")
theGlobeGeometry.firstMaterial.specular.contents = UIImage(named:"earth_specular.jpg")
// etc...
theGlobeGeometry.firstMaterial?.diffuse.contents = UIImage(named:"earth_diffuse.jpg")
theGlobeGeometry.firstMaterial?.ambient.contents = UIImage(named:"earth_ambient2.jpeg")
theGlobeGeometry.firstMaterial?.specular.contents = UIImage(named:"earth_specular.jpg")
// etc...