Questions tagged [swift3]

Use this tag only for questions directly related to changes in version 3 of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc for questions about developing on Apple platforms.

Swift 3 is the version of Apple's programming language Swift. It was released on September 13, 2016. The language is open source and available on Github (see ).

The development of Swift 3 and its goals can be viewed on the Swift Programming Language Evolution repository on Github.

For more information, please visit Swift's Getting Started page.

18453 questions
47
votes
4 answers

Selector in swift3

Why doesn't this work in swift 3 ? It crashes at runtime saying: '-[my_app_name.displayOtherAppsCtrl tap:]: unrecognized selector sent to instance 0x17eceb70' override func viewDidLoad() { super.viewDidLoad() // Uncomment the…
Chris
  • 1,231
  • 2
  • 10
  • 20
47
votes
7 answers

How to use AVCapturePhotoOutput

I have been working on using a custom camera, and I recently upgraded to Xcode 8 beta along with Swift 3. I originally had this: var stillImageOutput: AVCaptureStillImageOutput? However, I am now getting the warning: 'AVCaptureStillImageOutput'…
Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
46
votes
12 answers

upload image to server using Alamofire

this is my code that I want to upload image to server using Alamofire, it not error but it can't push image to server. what should I do? let url = URL(string: urlString)! var urlRequest = URLRequest(url: url) urlRequest.httpMethod = "POST" let…
Chea Sambath
  • 1,305
  • 2
  • 13
  • 16
46
votes
6 answers

Swift 3 : Decimal to Int

I tried to convert Decimal to Int with the follow code: Int(pow(Decimal(size), 2) - 1) But I get: .swift:254:43: Cannot invoke initializer for type 'Int' with an argument list of type '(Decimal)' Here I know pow is returning a Decimal but it…
Colin Wang
  • 6,778
  • 5
  • 26
  • 42
46
votes
4 answers

Swift 3 Alamofire multipart upload

Thanks to migration to Swift 3, I find it difficult to compile my project that uses Alamofire. The problem occurs when uploading multipartFormData: Alamofire.upload(.POST, URL, headers: headers, multipartFormData: { multipartFormData…
theDC
  • 6,364
  • 10
  • 56
  • 98
46
votes
6 answers

How to implement method swizzling swift 3.0?

How can I implement method swizzling in Swift 3.0 ? I've read nshipster article about it, but in this code's chunk struct Static { static var token: dispatch_once_t = 0 } the compiler gives me an error dispatch_once_t is unavailable in Swift:…
Tikhonov Aleksandr
  • 13,945
  • 6
  • 39
  • 53
46
votes
1 answer

Is there a writeToFile equivalent for Swift 3's 'Data' type?

I've some code which returns the new iOS 10 / Swift 3 NSData replacement(?) type: Data if let jpegData = UIImageJPEGRepresentation(newImage, 0.8) { ... } I want to write this image to disk, however NSData's writeToFile: method is not present for…
Kyle G
  • 4,347
  • 4
  • 26
  • 39
45
votes
5 answers

iOS view visibility gone

I am new to iOS development.I want to toggle (hide/visible) a subview from parent view.In android there is a way to hide the visibility to gone. In android subView.setVisibility(View.GONE); In iOS subView.removeFromSuperview() when i use above…
John
  • 3,769
  • 4
  • 12
  • 23
45
votes
8 answers

Change size of UIBarButtonItem (image) in Swift 3

I am trying to change the size of some icons in my navBar, but I am a little confused as to how to do this? My code so far is: func setUpNavBarButtons() { let moreButton = UIBarButtonItem (image:…
Sole
  • 3,100
  • 14
  • 58
  • 112
45
votes
4 answers

Quitting app causes error "Message from debugger: Terminated due to signal 9"

I'm writing a basic music player app but having some problems when it comes to handling the app state transitions. I'm using Swift 3 and MPMusicPlayerController.systemMusicPlayer() The goal is this: 1) Keep music playing when user taps the Home…
wayneh
  • 4,393
  • 9
  • 35
  • 70
45
votes
1 answer

Errors thrown from here are not handled

I've got this problem trying to parse a JSON on my iOS app: Relevant code: let jsonData:NSDictionary = try JSONSerialization.jsonObject(with: urlData! as Data, options: JSONSerialization.ReadingOptions.mutableContainers ) as! NSDictionary /* XCode…
TibiaZ
  • 730
  • 1
  • 8
  • 21
45
votes
5 answers

Working with NSNumber & Integer values in Swift 3

I am trying to convert my project to Swift 3.0 however I am having two error messages when working with NSNumber and Integers. Cannot assign type int to type NSNumber for //item is a NSManaged object with a property called index of type NSNumber…
A.Roe
  • 973
  • 3
  • 15
  • 34
44
votes
5 answers

swift 3.1 how to get array or dictionary from CSV

How could I use data in this kind of CSV file? Or how could I print for example row 2 value for "inside" column and assign it to a property / entity? I have this kind of file I got from excel file converted to Numbers, I'd like to grab data for each…
biggreentree
  • 1,633
  • 3
  • 20
  • 35
44
votes
2 answers

Make struct Hashable?

I'm trying to create a dictionary of the sort [petInfo : UIImage]() but I'm getting the error Type 'petInfo' does not conform to protocol 'Hashable'. My petInfo struct is this: struct petInfo { var petName: String var dbName: String } So I…
MarksCode
  • 8,074
  • 15
  • 64
  • 133
44
votes
4 answers

ISO8601DateFormatter doesn't parse ISO date string

I'm trying to parse this 2017-01-23T10:12:31.484Z using native ISO8601DateFormatter class provided by iOS 10 but always fails. If the string not contains milliseconds, the Date object is created without problems. I'm tried this and many options…
mhergon
  • 1,688
  • 1
  • 18
  • 39