


→ Xib (pronounced as "zib") file is a design file used by the MessageCell.swift.

→ Here, "Nib" is the old name for Xib.
→ awakeFromNib( ) initializes the xib file. Meaning however we customize the MessageCell.xib file, this method initializes it.



(Be careful of the parameters → There are a bunch of register( ) methods that you can choose from)

→ cellNibName has been pre-configured in the Constants.swift file, to prevent hardcoding String values everytime. The name is "MessageCell"
→ forCellReuseIdentifier must also be configured.

(Just like giving an identifier for a Segue, xib files also can be given an identifier)
→ K.cellIdentifier is also pre-configured in the Constants file. The name is "ReusableCell"
→ By following the above steps, we have now "registered" our table view

→ This way, each cell becomes the design of the xib file we configured earlier.

Optional : In my case, I'm making a chat bubble. To make the MessageCell look more like a bubble, we can tap into the below code.


Note: The Lines property for the Label must be set to 0 to present messages that go over a single line.

→ If we set the Line property to 0, no matter how long the message is, it will dynamically adjust.