Xcode 8 / Swift 3 : Simple UIPicker code not working

UIPickerViewDataSource method numberOfComponentsInPickerView is changed in Swift 3 like this that is the reason you are getting this error. func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return muteForPickerData.count } func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { … Read more

Xcode 8 – Missing Files warnings

This is just an Xcode bug. If you delete or rename a file without then doing a commit, Xcode sees the discrepancy between the previous git commit and the current state of things and reports these warnings. They go away as soon as you do a git add that includes the file deletion / rename.

“Creating an image format with an unknown type is an error” with UIImagePickerController

Below mentioned code did solve the problem for me – func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { if let image = info[UIImagePickerControllerOriginalImage] as? UIImage { imagePost.image = image } else{ print(“Something went wrong”) } self.dismiss(animated: true, completion: nil) }

URLSession.datatask with request block not called in background

If you want downloads to progress after your app is no longer in foreground, you have to use background session. The basic constraints of background sessions are outlined in Downloading Files in Background, and are essentially: Use delegate-based URLSession with background URLSessionConfiguration. Use upload and download tasks only, with no completion handlers. In iOS, Implement … Read more

UITextView with hyperlink text

Set isEditable = false or the text view will go into text-editing mode when user taps on it. Swift 4 and later let attributedString = NSMutableAttributedString(string: “Just click here to register”) let url = URL(string: “https://www.apple.com”)! // Set the ‘click here’ substring to be the link attributedString.setAttributes([.link: url], range: NSMakeRange(5, 10)) self.textView.attributedText = attributedString self.textView.isUserInteractionEnabled … Read more