2015-04-12 54 views
-2

XCode已更新並帶有新的Swift更新。XCode 6.3 Swift可轉換錯誤

我有這樣的代碼:

// load new tappable from file and place it on top of the screen beyond of sight 
tappable05 = CCBReader.load("Tappable") as Tappable 
tappable05.position = ccp(pipeSlim05.contentSize.width * 0.5, 
          pipeSlim05.contentSize.height * 1.03) 

tappable05.scale = 1.2 

//randomize tappable color 
tappable05.setRandomColor() 

// setup zOrder 
tappable05.zOrder = DrawingOrder.DrawingOrderTappable.rawValue 

// add new tappable to scene 
pipeSlim05.addChild(tappable05) 

而且我得到這個錯誤:

CCNode! is not convertible to 'Tappable;' dod you mean to use 'as!' 
+1

是的。 Swift 1.2(在Xcode 6.3中)的新功能現在需要'as!'。你有沒有嘗試將它改爲'as!可打字嗎? – vacawama

+1

夥計使用他們包括的轉換器。它會解決所有這些問題。 – Rob

回答

0

這是1.2中最常見的變化,向下轉換所需要的!

有一個轉換器,將解決這個問題,在這裏:

enter image description here

或者使用速戰速決,但是這是一個不必要的麻煩。

相關問題