xcode - DynamoDB Swift Table Scan Mapping Class -
i trying simple table scan aws , dynamodb using swift. new apple programming , not sure issue is. documentation aws sdk in objective c , examples aws give swift rubbish.
the best info got question here have been trying work through it.
best way make amazon aws dynamodb queries using swift?
there many error 1 question break multiple questions:
the first part tried class item defines mapping database "item"
i have written code , errors getting underneath each line in bold:
class item : nsobject, awsdynamodbmodel, awsdynamodbmodeling {
'item' not conform protocol 'awsdynamodbmodeling'
var artist : string = "" var songtitle : string = "" var albumtitle : string = "" var category : string = "" var pictureurl : string = "" var songurl : string = "" var location : string = "" var avgmusicianrating : int = 0 var avguserrating : int = 0 var songduration : int = 0 var songid : int = 0 override init!() { super.init() }
failable initializer 'init()' cannot override non-failable initializer
required init!(coder: nscoder!) { fatalerror("init(coder:) has not been implemented") } class func dynamodbtablename() -> string! { return "songs" } class func hashkeyattribute() -> int! { return songid }
instance member 'songid' cannot used on type 'item' (my hash key int not string)
//required let dynamodb mapper create instances of class override init(dictionary dictionaryvalue: [nsobject : anyobject]!, error: nserrorpointer)
initializer not override designated initializer superclass
{ super.init(dictionary: dictionaryvalue, error: error) } //workaround possible xcode 6.1 bug : "type notificationack" not conform protocol "nsobjectprotocol" override func isequal(anobject: anyobject?) -> bool { return super.isequal(anobject) } }
thanks in advance.
1. 'item' not conform protocol 'awsdynamodbmodeling'
replace
class func hashkeyattribute() -> int! { return songid }
by
class func hashkeyattribute() -> string! { return "songid" }
explanation: need provide name of hashkey attribute, not it's type. protocol requires return string.
2. failable initializer 'init()' cannot override non-failable initializer
there no need extend nsobject. can remove init(..) methods code. far can see not needed.
3. instance member 'songid' cannot used on type 'item' (my hash key int not string)
this go away when fix error 1.
4. initializer not override designated initializer superclass
this go away when fix error 2
i wrote tutorial using dynamodb swift app. part 3 contains simple example of class amzuser mapped dynamodb
Comments
Post a Comment