2

I'm new to Swift and am making my first Backendless database query using their api. I followed this tutorial.

Here's the code:

func fetchingFirstPageAsync() {
    let startTime = NSDate()

    let query = BackendlessDataQuery()
    backendless.persistenceService.of(Player.ofClass()).find(
        query,
        response: { ( players : BackendlessCollection!) -> () in 
            let currentPage = players.getCurrentPage()
            let playersAvailable = currentPage as! [Player] 
            print(playersAvailable[0].club) // This is working
        },
        error: { ( fault : Fault!) -> () in
            print("Server reported an error: \(fault)")
        }
    )
}

The function works fine but I don't understand how I can get the response inside the closure into another class.

How can I retrieve an array of players inside a class using fetchingFirstPageAsync()?

Stiño
  • 2,663
  • 7
  • 25
  • 47
  • Or this one: http://stackoverflow.com/questions/27081062/swift-how-do-i-return-a-value-within-an-asynchronous-urlsession-function – Just search for "swift how to return from asynchronous method" and you'll find similar questions with answers. – Martin R Apr 09 '16 at 10:26

0 Answers0