Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Recursive function to preload array of PFObjects
Recusivly pre load an array of PFObjects.
- parameter items: The items to preload.
- parameter completion: Invoked once all loading in the background has been completed. If an error occured it will be passed back otherwise `success` will be `true` with a `nil` error parameter.
func preloadItems(items: [PFObject], completion: (success: Bool, error: NSError?) -> ()) {
func recursiveLoad(index: Int) {
if index == items.count {
completion(success: true, error: nil)
items[index].fetchInBackgroundWithBlock({ (object, error) in
if let err = error {
completion(success: false, error: err)
else {
recursiveLoad(index + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.