swift中采用的objective-c协议

时间:2016-03-20 12:33:28

标签: ios delegates appdelegate

这是我使用的框架中的客观c协议

@protocol AWSDKDelegate <NSObject>

/*
 * @abstract    AWSDKDelegate initialization lifecycle notifications to inform your app of success or failure
 in SDK initialization and profile retrieval.
 */
- (void)initialCheckDoneWithError:(NSError*) error;
- (void)receivedProfiles:(NSArray*)profiles;

/*
 * @abstract    AWSDKDelegate Action Notifications used to inform your app to take various action
 * @discussion  stopNetworkActivity and resumeNetworkActivity are not supported on iOS 9
 */
- (void)wipe;
- (void)lock;
- (void)unlock;
- (void)stopNetworkActivity;
- (void)resumeNetworkActivity;
@end

创建桥接头后,我试图在我用Swift编写的应用程序中采用它

//MARK: AWSDKDelegate Methods

    func initialCheckDoneWithError(error: NSError!) {}
    func receivedProfiles(profiles: NSArray!) {}
    func unlock() {}
    func wipe() {}
    func stopNetworkActivity() {}
    func resumeNetworkActivity() {}

但仍然有这个错误:

Type 'AppDelegate' does not conform to protocol 'AWSDKDelegate'

1 个答案:

答案 0 :(得分:0)

1)忘记实现锁定方法 2)我不知道为什么,但事实证明使用NSArray的合适方式是[AnyObject]。所以func receivedProfiles(profiles: [AnyObject]!)代替func receivedProfiles(profiles: NSArray!)

无论如何,我想知道为什么XCode没有对这类错误进行更详细的描述。