简体   繁体   中英

objective-c protocol adopted in swift

This is objective c protocol placed in framework I use

@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

After creating bridge header I'm trying to adopt it in my app written in Swift

//MARK: AWSDKDelegate Methods

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

But still got this error:

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

1) Forget to implement lock method 2) I don't know why, but it turns out the appropriate way of using NSArray is [AnyObject] . So func receivedProfiles(profiles: [AnyObject]!) instead of func receivedProfiles(profiles: NSArray!)

Anyway, I'm wonder why XCode hasn't a more detailed description of those type of errors..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM