2016-07-14 3 views
0

나는 신속한 ViewController를 사용하는 혼합 프로젝트에서 작업하고 있습니다. C++ 코드와 목적 C 클래스는 C++ 클래스의 래퍼 역할을합니다. 지금까지 개발 된 부분이 효과적입니다.스위프트 ViewController, 객관적인 C 프로토콜, 유형 'ViewController'프로토콜 'MyProtocolDelegate'을 준수하지 않습니다

@protocol MyProtocolDelegate <NSObject> 
    - (void)updateCount:(int)count; 
@end 
@interface CvVideoCameraWrapper : NSObject 
@property (weak,nonatomic) id <MyProtocolDelegate> delegate; 
    //remaining of my interface 
@end 

I가 준수하고 추가의 ViewController 다른 프로토콜에 MyProtocolDelegate을 추가 신속한 코드에서 :

class ViewController: UIViewController, CvVideoCameraDelegate, UITextFieldDelegate, MyProtocolDelegate{ 

    func updateCount(count:Int) 
    { 
     return 
    } 
    override func viewDidLoad() { 
     super.viewDidLoad()   
     self.typedName.delegate = self // this one works 
     self.videoCameraWrapper.delegate = self 
     // remaining of my viewDidLoad 
    } 
     //remaining of my ViewController 
} 

컴파일러에 오류가 표시 난 그냥 하나의 방법 선언 목표 C에서 간단한 프로토콜을 추가했습니다 : 'ViewController'유형이 'MyProtocolDelegate'프로토콜을 준수하지 않습니다.

객관적인 C 언어로 선언 된 대리자 메서드 서명과 신속한 일치를 알 수 없습니다 C와 Int는 신속하게 동일하지만, 신속하고 객관적인 C 및 C++의 브리징 및 다른 상호 작용이 신속하게 이루어짐을 이해합니다. 이 프로토콜의 사용에있어 잘못된 점을 지적하십시오.

+0

ObjC'int' 봐 내가 믿는 스위프트'Int32'과 동일을 할 것이다. – dan

+0

'MyProtocolDelegate'에 필요한 모든 메소드를 구현했는지 확인하십시오 – chengsam

+0

프로토콜 메소드 선언에'NSInteger'를 사용해야합니다. – AdamPro13

답변

0

신속한 유형 Int32는 obj-c int에 해당하는 정확한 내용

하지만 혼동을 피하기 위해 C 유형 별명을 사용해야합니다. 당신의 예에서 는

func updateCount(count:CInt) 
{ 
    return 
} 

Apple - Interacting with C APIs

관련 문제