hasen's tech life

Twitter: @hasen

Swift3系対応で行なった修正メモ.

# Swift3系対応で行なった修正メモ.

> queryLimitedToLast has been renamed to queryLimited(toLast)
-- queryLimitedToLast(100)
++ queryLimited(toLast: 100)

> Type 'Any' has no subscript members
http://swift-labo.net/2016/10/02/117/
-- let text = snapshot.value!["text"] as! String
++ let snapshotValue = snapshot.value as! NSDictionary
++ let text = snapshotValue["text"] as! String

> Argument labels '(_:, diameter:)' do not match any available overloads
-- self.outgoingAvatar = JSQMessagesAvatarImageFactory.avatarImage(UIImage(named: "icon_default")!, diameter: 64)
++

> Use of unresolved identifier 'bubbleFactory'
-- let bubblefactory =
++ let bubbleFactory =

> Value of optional type 'JSQMessagesBubbleImageFactory?' not unwrapped; did you mean to use '!' or '?'?
-- self.outgoingBubble = bubbleFactory.outgoingMessagesBubbleImageWithColor(UIColor.jsq_messagesBubbleGreenColor())
++ self.incomingBubble = bubbleFactory?.incomingMessagesBubbleImage(with: UIColor.jsq_messageBubbleLightGray())

> Method does not override any method from its superclass
-- override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
++ override func collectionView(_ collectionView: JSQMessagesCollectionView!, messageDataForItemAt indexPath: IndexPath!) -> JSQMessageData! {

> 'JSQMessagesBubbleImage!' is not convertible to 'JSQMessageData!'; did you mean to use 'as!' to force downcast?
-- return self.outgoingBubble
++ return self.outgoingBubble as! JSQMessageData!

> Missing argument label 'text:' in call
-- sendTextToDb(text)
++ sendTextToDb(text: text)

> 'unsafeAddress(of:)' is unavailable: Removed in Swift 3. Use Unmanaged.passUnretained(x).toOpaque() instead.
-- unsafeAddress(of: kCGImagePropertyGIFUnclampedDelayTime)
++ Unmanaged.passUnretained(kCGImagePropertyGIFUnclampedDelayTime).toOpaque()

> Switch must be exhaustive, consider adding a default clause
++ default:
++ return 0

-- Dictionary<String, String>
++ [String, String]