I have the following code from Ray Wenderlich's Core Data by Tutorials Second Edition:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
guard let note = notes.fetchedObjects?[indexPath.row] as? Note else {
return UITableViewCell()
}
let identifier = note.image == nil ? "NoteCell" : "NoteCellImage"
if let cell = tableView.dequeueReusableCellWithIdentifier( identifier, forIndexPath: indexPath) as? NoteTableViewCell {
cell.note = note
return cell
}
return UITableViewCell()
}
I do not understand what the guard statement does.
The Swift Programming Language documentation (https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html) says:
A
guard statement is used to transfer program control out of a scope if one or more conditions aren’t met.I understand what scope is, but I don't understand how it is applied in this description of the guard statement.
Can someone explain this to me?