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
44
votes
3 answers

Swift 3.0 Error: Escaping closures can only capture inout parameters explicitly by value

I'm trying to update my project to Swift 3.0 but I have some difficulties. I'm getting next error: "Escaping closures can only capture inout parameters explicitly by value". The problem is inside this function: fileprivate func collectAllAvailable(_…
walkline
  • 443
  • 1
  • 5
  • 5
44
votes
7 answers

How to show UIAlertController from Appdelegate

I'm working with PushNotification on iOS app. I would like to show a UIalertcontroller when the app receive a notification. I try this code below in the AppDelegate: [self.window.rootViewController presentViewController:alert animated:YES…
Rockers23
  • 775
  • 1
  • 12
  • 24
44
votes
11 answers

How can I switch views programmatically in a view controller? (Xcode, iPhone)

Have been struggling with this for a while, and can never seem to get a direct answer. Any help is appreciated!
mishajw126
  • 517
  • 1
  • 5
  • 14
43
votes
5 answers

How to build Swift 3 project on Xcode 9?

Xcode 9 Release Notes says that Swift 3 compilation is supported: One compiler for Swift 4 and Swift 3, Swift 4 and Swift 3 targets can be compiled together in the same project. I have installed Xcode 9 beta. But when I press Build it shows bunch…
Exey Panteleev
  • 1,260
  • 3
  • 13
  • 15
43
votes
11 answers

How to present a ViewController on Half screen

I have a UIViewController which have only a UIView which covers 1/3 of the viewController from bottom. Like this I want to present this viewController on an other ViewController. It should appear from bottom animated and it should dismiss to the…
Umair Afzal
  • 4,947
  • 5
  • 25
  • 50
43
votes
9 answers

Converting Boolean value to Integer value in Swift

I was converting from Swift 2 to Swift 3. I noticed that I cannot convert a boolean value to integer value in Swift 3. let p1 = ("a" == "a") //true print(true) //"true\n" print(p1) //"true\n" Int(true) …
Shubhashis
  • 10,411
  • 11
  • 33
  • 48
43
votes
1 answer

Handling try and throws in Swift 3

Before Swift 3 I was using: guard let data = Data(contentsOf: url) else { print("There was an error!) return } However I now have to use do, try and catch. I'm not familiar with this syntax. How would I…
KexAri
  • 3,867
  • 6
  • 40
  • 80
43
votes
3 answers

"Cannot inherit from non-open class" swift

As of Xcode 8 beta 6 I now get the compile error "Cannot inherit from non-open class (Class)" outside of its defining module" The class I was inheriting from was part of a separate Swift framework but my project compiled for Xcode 8 beta 5. What do…
LOP_Luke
  • 3,150
  • 3
  • 22
  • 25
43
votes
7 answers

Duplicate files in DerivedData folder using CoreData generator

I'm trying to generate NSManagedModels from my datamodel. Generation works but after I got many errors : error: filename "Station+CoreDataProperties.swift" used twice: '/Users/Me/MyApp/Models/CoreData/Station+CoreDataProperties.swift' and …
Ludovic
  • 1,992
  • 1
  • 21
  • 44
42
votes
6 answers

Core data: Failed to load model

I am new to core data. What I am trying to DO: I am trying to create a cocoatouch framework that has an app to add employee details and display them in a table view. So that i can add this framework to my main project to work independently. Issues I…
Ashiq Sulaiman
  • 631
  • 1
  • 6
  • 14
42
votes
7 answers

Add a button on right view of UItextfield in such way that, text should not overlap the button

I can add a button to a textfield on the right hand side of the UITextField using the right view however, the text overlaps on the button. Below is the code for right view button UIView.commitAnimations() var btnColor =…
Saty
  • 2,563
  • 3
  • 37
  • 88
42
votes
9 answers

Swift 3 / Xcode 8 Upgrade - 100's of DerivedData files missing from working copy errors

I have just upgraded to the latest Beta version of XCode and Swift but after using the converter my app project now has over 200 build time yellow errors all stating /"projectDirectoy"/DerivedData/XXXXXXXXX/XXXX/XXX/xXXX/xXX is missing from working…
Krivvenz
  • 3,911
  • 3
  • 22
  • 32
42
votes
5 answers

How do you enumerate OptionSetType in Swift?

I have a custom OptionSetType struct in Swift. How can I enumerate all values of an instance? This is my OptionSetType: struct WeekdaySet: OptionSetType { let rawValue: UInt8 init(rawValue: UInt8) { self.rawValue = rawValue } …
Florian
  • 5,326
  • 4
  • 26
  • 35
41
votes
2 answers

Swift 3 - Check if WKWebView has loaded page

My question: How do I check if a page in WKWebView has fully loaded in Xcode using Swift 3? This is my problem: Webpage 1: From this page I load Webpage 2 Webpage 2: I need to get html data from Webpage 2, but when I print the HTML data I get HTML…
Stef
  • 1,183
  • 1
  • 9
  • 12
41
votes
1 answer

Swift 3 Decimal, NSDecimal and NSDecimalNumber

I am trying to use NumberFormatter with Swift 3 Decimal, but I'm confused as to how Decimal is really being implemented. The problem I'm having is that Decimal is a struct, so I have to bridge it to an NSDecimalNumber every time I want to use a…
Alex
  • 3,861
  • 5
  • 28
  • 44