kingofthenorth
kingofthenorth

Reputation: 3

Swift Callback API assistance

When calling getItems function, XCode auto completes to:

getItems(success: (([File]) -> ())?, fail: ((Error) -> ())?)

I just need some assistance understanding what I need to input in order to get the list of items.

I've created simple callbacks and read up on Apple's closure documentation to better understand what's going on but am still a little confused by this in particular.

Upvotes: 0

Views: 51

Answers (1)

sCha
sCha

Reputation: 1504

You'll have to put closures as parameters like below to use this function:

getItems(success: { (files) in
    // files: [File]
    for file in files {
        print(file)
    }
}, fail: { (error) in 
    // error: Error
    print(error)
})

Upvotes: 1

Related Questions