Swift : Type XXX must conform to protocol 'NSObjectProtocol' Swift : Type XXX must conform to protocol 'NSObjectProtocol' ios ios

Swift : Type XXX must conform to protocol 'NSObjectProtocol'


Just inherit from NSObject:

class DDBItem : NSObject, AWSDynamoDBModel, AWSDynamoDBModeling {


Self answered for sake of archiving.

When adding

override func isEqual(anObject: AnyObject?) -> Bool {    return super.isEqual(anObject)}

to my class, it works.This method should have been inherited from the base class.

Looks like a bug in Swift / Xcode 6.1 to me


Just a heads up for those that stumble upon this post. AWSDynamoDBModeling protocol has been changed in the latest SDK (v2.1.1). Required functions: dynamoDBTableName and hashKeyAttribute must be static. The documentation as of today (5/27/2015) appears to be out of date.

Example:

class Dingle:AWSDynamoDBObjectModel, AWSDynamoDBModeling {    static func dynamoDBTableName() -> String! {        return "dev_coupons"    }    static func hashKeyAttribute() -> String! {        return "status "    }    func rangeKeyAttribute() -> String! {        return "post_date"    }    override func isEqual(object: AnyObject?) -> Bool {        return super.isEqual(object)    }}


matomo