2016-07-28 40 views
0

要排除一個項目的問題,我創建了一個全新的單一視圖項目,並增加了以下podfile:火力地堡3:不明確使用「observeEventType(_:withBlock :)」

target 'App' do 
    use_frameworks! 

    pod 'Firebase' 
    pod 'Firebase/Auth' 
    pod 'Firebase/Database' 
end 

我接着又說了以下代碼:

import UIKit 
import FirebaseDatabase 

class ViewController: UIViewController { 

    let ref = FIRDatabase.database().reference() 

    override func viewDidAppear(animated: Bool) { 
     super.viewDidAppear(animated) 

     ref.observeEventType(.Value) { (snapshot) in 

     } 
    } 
} 

結果是以下錯誤:

Ambiguous use of 'observeEventType(_:withBlock:)'

與:

Found this candidate (FirebaseDatabase.FIRDatabaseReference)

Found this candidate (FirebaseDatabase.FIRDatabaseReference)

我使用的Xcode 7.3.1和podfile.lock如下:

PODS: 
    - Firebase (3.3.0): 
    - Firebase/Core (= 3.3.0) 
    - Firebase/Analytics (3.3.0): 
    - FirebaseAnalytics (= 3.2.1) 
    - Firebase/Core (3.3.0): 
    - Firebase/Analytics (= 3.3.0) 
    - Firebase/Database (3.3.0): 
    - Firebase/Analytics (= 3.3.0) 
    - FirebaseDatabase (= 3.0.2) 
    - FirebaseAnalytics (3.2.1): 
    - FirebaseInstanceID (~> 1.0) 
    - GoogleInterchangeUtilities (~> 1.2) 
    - GoogleSymbolUtilities (~> 1.1) 
    - GoogleUtilities (~> 1.3) 
    - FirebaseDatabase (3.0.2): 
    - FirebaseAnalytics (~> 3.2) 
    - FirebaseInstanceID (1.0.7) 
    - GoogleInterchangeUtilities (1.2.1): 
    - GoogleSymbolUtilities (~> 1.0) 
    - GoogleSymbolUtilities (1.1.1) 
    - GoogleUtilities (1.3.1): 
    - GoogleSymbolUtilities (~> 1.0) 

DEPENDENCIES: 
    - Firebase 
    - Firebase/Database 

SPEC CHECKSUMS: 
    Firebase: 6250071f0e2440a5c4c67b8cb6b868f868237ac3 
    FirebaseAnalytics: 0fd6532cb2c3d03cd5cf26ad295ccb091efd3104 
    FirebaseDatabase: 59bea2e7dfd81b3b8b2f8e396caf1a52c2ced6f7 
    FirebaseInstanceID: a9d923f3d0b6fbf9fac89310860357aaadc34be5 
    GoogleInterchangeUtilities: def8415a862effc67d549d5b5b0b9c7a2f97d4de 
    GoogleSymbolUtilities: 33117db1b5f290c6fbf259585e4885b4c84b98d7 
    GoogleUtilities: 56c5ac05b7aa5dc417a1bb85221a9516e04d7032 

PODFILE CHECKSUM: 261a8ee435b8325808d7a0962ace0c908fd37368 

COCOAPODS: 1.0.1 

observeSingleEventOfType(_:withBlock:)

回答

7

同樣的問題,這似乎就像是一個Swift bug,嘗試使用此語法代替(無拖尾的閉包語法):

ref.observeEventType(.Value, withBlock: { firDataSnapshot in 

}) 

更多信息:Ambiguous use of 'observeSingleEventOfType(_:withBlock:)' error in Swift

+0

是的,解決了它!奇怪的一個...當我扔了一個打印語句它編譯好了,但封閉中的任何其他代碼會拋出錯誤......謝謝! – doovers

+0

@多餘我一直在那裏:/ – iOSGeek