Я хочу разрешить выбор определенной строки, в результате чего произойдет действие, описанное ниже:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
// Ensure controller knows which dataset to pull from,
// so detail view is correct
var friendChat: Friend!
friendChat = mappedFriends[indexPath.row]
// Now set the conditional cases: if a friend then chat, if user then friend request if not user then can invite them:
if(friendChat.statusSort == 2) {
var controller : IndividualChatController!
print(friendChat.name)
controller.friendChat? = friendChat
controller.senderId? = Global.sharedInstance.userID
controller.senderDisplayName? = Global.sharedInstance.userName
self.performSegueWithIdentifier("showIndividualChat",sender: controller)
} else
if (friendChat.statusSort == 1) {
print("Can invite to be friend")
} else if (friendChat.statusSort == 0) {
print("Invite to Feast")
}
}
Тем не менее, во время назначения, из:
controller.friendChat? = friendChat
controller.senderId? = FeastGlobal.sharedInstance.userID
controller.senderDisplayName? = FeastGlobal.sharedInstance.userName
Появляется ошибка: fatal error: unexpectedly found nil while unwrapping an Optional value
.
Почему это может произойти? Как это можно облегчить?