@@ -23,6 +23,12 @@ class MessageViewController: SLKTextViewController {
23
23
24
24
var editingMessage = Message ( )
25
25
26
+ override var tableView : UITableView {
27
+ get {
28
+ return super. tableView!
29
+ }
30
+ }
31
+
26
32
27
33
// MARK: - Initialisation
28
34
@@ -33,7 +39,7 @@ class MessageViewController: SLKTextViewController {
33
39
34
40
func commonInit( ) {
35
41
36
- NSNotificationCenter . defaultCenter ( ) . addObserver ( self . tableView! , selector: #selector( UITableView . reloadData) , name: UIContentSizeCategoryDidChangeNotification, object: nil )
42
+ NSNotificationCenter . defaultCenter ( ) . addObserver ( self . tableView, selector: #selector( UITableView . reloadData) , name: UIContentSizeCategoryDidChangeNotification, object: nil )
37
43
NSNotificationCenter . defaultCenter ( ) . addObserver ( self , selector: #selector( MessageViewController . textInputbarDidMove ( _: ) ) , name: SLKTextInputbarDidMoveNotification, object: nil )
38
44
39
45
// Register a SLKTextView subclass, if you need any special appearance and/or behavior customisation.
@@ -80,10 +86,8 @@ class MessageViewController: SLKTextViewController {
80
86
self . typingIndicatorView!. canResignByTouch = true
81
87
}
82
88
83
- if let tableView = self . tableView {
84
- tableView. separatorStyle = . None
85
- tableView. registerClass ( MessageTableViewCell . classForCoder ( ) , forCellReuseIdentifier: MessengerCellIdentifier)
86
- }
89
+ self . tableView. separatorStyle = . None
90
+ self . tableView. registerClass ( MessageTableViewCell . classForCoder ( ) , forCellReuseIdentifier: MessengerCellIdentifier)
87
91
88
92
self . autoCompletionView. registerClass ( MessageTableViewCell . classForCoder ( ) , forCellReuseIdentifier: AutoCompletionCellIdentifier)
89
93
self . registerPrefixesForAutoCompletion ( [ " @ " , " # " , " : " , " +: " , " / " ] )
@@ -236,7 +240,7 @@ extension MessageViewController {
236
240
self . editingMessage = self . messages [ cell. indexPath. row]
237
241
self . editText ( self . editingMessage. text)
238
242
239
- self . tableView! . scrollToRowAtIndexPath ( cell. indexPath, atScrollPosition: . Bottom, animated: true )
243
+ self . tableView. scrollToRowAtIndexPath ( cell. indexPath, atScrollPosition: . Bottom, animated: true )
240
244
}
241
245
242
246
func editRandomMessage( sender: AnyObject ) {
@@ -256,14 +260,14 @@ extension MessageViewController {
256
260
return
257
261
}
258
262
259
- let lastSectionIndex = self . tableView! . numberOfSections- 1
260
- let lastRowIndex = self . tableView! . numberOfRowsInSection ( lastSectionIndex) - 1
263
+ let lastSectionIndex = self . tableView. numberOfSections- 1
264
+ let lastRowIndex = self . tableView. numberOfRowsInSection ( lastSectionIndex) - 1
261
265
262
266
let lastMessage = self . messages [ lastRowIndex]
263
267
264
268
self . editText ( lastMessage. text)
265
269
266
- self . tableView! . scrollToRowAtIndexPath ( NSIndexPath ( forRow: lastRowIndex, inSection: lastSectionIndex) , atScrollPosition: . Bottom, animated: true )
270
+ self . tableView. scrollToRowAtIndexPath ( NSIndexPath ( forRow: lastRowIndex, inSection: lastSectionIndex) , atScrollPosition: . Bottom, animated: true )
267
271
}
268
272
269
273
func togglePIPWindow( sender: AnyObject ) {
@@ -382,16 +386,16 @@ extension MessageViewController {
382
386
let rowAnimation : UITableViewRowAnimation = self . inverted ? . Bottom : . Top
383
387
let scrollPosition : UITableViewScrollPosition = self . inverted ? . Bottom : . Top
384
388
385
- self . tableView! . beginUpdates ( )
389
+ self . tableView. beginUpdates ( )
386
390
self . messages. insert ( message, atIndex: 0 )
387
- self . tableView! . insertRowsAtIndexPaths ( [ indexPath] , withRowAnimation: rowAnimation)
388
- self . tableView! . endUpdates ( )
391
+ self . tableView. insertRowsAtIndexPaths ( [ indexPath] , withRowAnimation: rowAnimation)
392
+ self . tableView. endUpdates ( )
389
393
390
- self . tableView! . scrollToRowAtIndexPath ( indexPath, atScrollPosition: scrollPosition, animated: true )
394
+ self . tableView. scrollToRowAtIndexPath ( indexPath, atScrollPosition: scrollPosition, animated: true )
391
395
392
396
// Fixes the cell from blinking (because of the transform, when using translucent cells)
393
397
// See https://github.com/slackhq/SlackTextViewController/issues/94#issuecomment-69929927
394
- self . tableView! . reloadRowsAtIndexPaths ( [ indexPath] , withRowAnimation: . Automatic)
398
+ self . tableView. reloadRowsAtIndexPaths ( [ indexPath] , withRowAnimation: . Automatic)
395
399
396
400
super. didPressRightButton ( sender)
397
401
}
@@ -434,7 +438,7 @@ extension MessageViewController {
434
438
override func didCommitTextEditing( sender: AnyObject ) {
435
439
436
440
self . editingMessage. text = self . textView. text
437
- self . tableView! . reloadData ( )
441
+ self . tableView. reloadData ( )
438
442
439
443
super. didCommitTextEditing ( sender)
440
444
}
@@ -555,7 +559,7 @@ extension MessageViewController {
555
559
556
560
func messageCellForRowAtIndexPath( indexPath: NSIndexPath ) -> MessageTableViewCell {
557
561
558
- let cell = self . tableView! . dequeueReusableCellWithIdentifier ( MessengerCellIdentifier) as! MessageTableViewCell
562
+ let cell = self . tableView. dequeueReusableCellWithIdentifier ( MessengerCellIdentifier) as! MessageTableViewCell
559
563
560
564
if cell. gestureRecognizers? . count == nil {
561
565
let longPress = UILongPressGestureRecognizer ( target: self , action: #selector( MessageViewController . didLongPressCell ( _: ) ) )
@@ -572,7 +576,7 @@ extension MessageViewController {
572
576
573
577
// Cells must inherit the table view's transform
574
578
// This is very important, since the main table view may be inverted
575
- cell. transform = self . tableView! . transform
579
+ cell. transform = self . tableView. transform
576
580
577
581
return cell
578
582
}
0 commit comments