dimanche 1 février 2015

Swift - Passing DynamoDB Paginated Output results to function in another class

I am trying to pass the results of a DynamoDB function set-up in my Amazon.swift 'AWS' class back to my ViewController. The aim is to use the data to create GPS points on a map (the ViewController has the full MapKit / mapView setup).


This is the DynamoDB function:



func read_multipin_data() -> AWSDynamoDBPaginatedOutput {

let cond = AWSDynamoDBCondition()
let v1 = AWSDynamoDBAttributeValue(); v1.S = ADate
cond.comparisonOperator = AWSDynamoDBComparisonOperator.EQ
cond.attributeValueList = [ v1 ]

let exp = AWSDynamoDBScanExpression()
exp.scanFilter = [ "date" : cond ]

self.scan(exp).continueWithSuccessBlock({ (task: BFTask!) -> BFTask! in
let results = task.result as AWSDynamoDBPaginatedOutput
return results // Error: 'AWSDynamoDBPaginatedOutput' is not convertible to 'BFTask'
})
}

func scan(expression : AWSDynamoDBScanExpression) -> BFTask! {

let mapper = AWSDynamoDBObjectMapper.defaultDynamoDBObjectMapper()
return mapper.scan(AWS.self, expression: expression)
}


The second function which currently merely attempts to recover the data in my ViewController is:



@IBAction func refresh_db_pins(){

let all_annotations_in: AWSDynamoDBPaginatedOutput = AWS().read_multipin_data()

}


The error I am getting when I try to return the results is: 'AWSDynamoDBPaginatedOutput' is not convertible to 'BFTask'


I have tried many different approaches including converting the JSON formatted data into arrays, dictionaries, alas nothing worked.


Many thanks in advance for your help!





Aucun commentaire:

Enregistrer un commentaire