I'm looking for doing a loop on an array but want to stop after a condition. This is what I have now (btw, I'm using Parse as back-end).
let query = PFQuery(className: "MyObject")
query.whereKey("user", equalTo: PFUser.currentUser())
query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -> Void in
if error == nil {
for object in objects {
print(object.objectId)
}
}
}
This code is printing every objectId.
Now let's imagine I want to print every object until my find an object with objectId == "xxx".
How should I do that?