Toggle Sidebar   Previous Lesson Complete and Continue  

  Update Code to Swift 4.2 and Firebase 5

Due to the best practices we applied to the course, it takes a minimal effort to update our project to Swift 4.

This note covers the most significant changes in Swift 4.2 for the Instagram Project.

In Swift 4

  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
        print("did Finish Picking Media")
        if let image = info["UIImagePickerControllerOriginalImage"] as? UIImage{
            selectedImage = image
            profileImage.image = image
        }
        dismiss(animated: true, completion: nil)
  }
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        UITabBar.appearance().tintColor = .black
        FirebaseApp.configure()
        return true
  }
  UIImage.JPEGRepresentation(profileImg, 0.1)
  UICollectionElementKindSectionHeader
  NSNotification.Name.UIKeyboardWillShow
  NSNotification.Name.UIKeyboardWillHide
  UIKeyboardFrameEndUserInfoKey
  UIPageViewControllerNavigationDirection.forward
  imageGenerator.copyCGImage(at: CMTimeMake(7, 1), actualTime: nil)
  NSAttributedStringKey 
  UIControlEvents
  NSAttributedStringKey
  UITableViewAutomaticDimension
	


In Swift 4.2

  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
      if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage{
            selectedImage = image
            profileImage.image = image
      }
      dismiss(animated: true, completion: nil)
  }
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        UITabBar.appearance().tintColor = .black
        FirebaseApp.configure()
        return true
  }
  profileImg.jpegData(compressionQuality: 0.1)   
  UICollectionView.elementKindSectionHeader
  UIResponder.keyboardWillShowNotification
  UIResponder.keyboardWillHideNotification
  UIResponder.keyboardFrameEndUserInfoKey
  UIPageViewController.NavigationDirection.forward
  imageGenerator.copyCGImage(at: CMTimeMake(value: 7, timescale: 1), actualTime: nil)
  NSAttributedString.Key
  UIControl.Event
  UITableView.automaticDimension
	


The source code is now available in Swift 4.2 and Firebase 5 SDKs compatible with the latest Xcode 10 (see lecture 96 for the Firebase 5 documentation).

Complete and Continue  
Discussion

12 comments