This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overrides tableView in the Swift sample project, to avoiding unwrappi…
…ng too many times.
- Loading branch information
Ignacio Romero Zurbuchen
committed
Apr 27, 2016
1 parent
e5be026
commit 35d7df9
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35d7df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzenbot Hi I'm using slack view controller in my app. I have a question about the updates to the tableView becoming an optional. In your example, you're force-unwrapping it, is it a recommended way of using it? isn't it crashing the app if it's nil?
35d7df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yanjinww: because
tableView
is an optional (since you can either initialise the view controller to be using a collectionView or scrollView) it is necessary to unwrap.But you might find this useful as it will allow you to no unwrap everywhere, just once:
#450 (comment)
I should update the sample project with this solution instead.
35d7df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @dzenbot your answer is very helpful. follow-up question:
does the "return super.tableView!" guarantee to return non-nil value or still can be nil in the case of the code above?