Firebase에서 사용자 데이터를 가져와 필요한 경우 현재 화면을 업데이트하는 매우 기본적인 사용자 클래스가 있습니다. 프로젝트를 업데이트하기로 결정할 때까지 모든 것이 작동했습니다.Swift 2.3에서 Swift 3.0으로 업데이트 한 후 클래스 프로토콜이 작동하지 않음
class FirstViewController: UIViewController, userClassProtocol {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
print("View will load")
User.sharedInstance.delegate = self
}
func updateScreen() {
print("Screen is going to update")
//Do stuff here
}
}
내가이에서 얻을 로그는 다음과 같습니다 : 스위프트 3.0
에 이것은의 ViewController 사용자 클래스
@objc protocol userClassProtocol {
func updateScreen()
@objc optional func sucessUnlockedCategory()
}
class User {
static let sharedInstance = User()
internal var delegate : userClassProtocol?
func fakeClassThatGetsDataFromFirebase() {
//Got data
print("Has new data")
self.delegate?.updateScreen()
}
}
입니다 그리고 여기 새로운 데이터 있음 보기가 나타납니다
그러나 뷰 컨트롤러의 updateScreen() 함수는 결코 호출되지 않습니다. Xcode는 오류를 지적하지 않습니다.
위임을 설정 한 후 fakeClassThatGetsDataFromFirebase를 호출합니까? –