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
51
votes
5 answers

Getting local notifications to show while app is in foreground Swift 3

Apparently this is now possible with ios10 : optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler:…
user6820041
  • 1,213
  • 2
  • 13
  • 29
51
votes
2 answers

Selector syntax for swift 3.0

I am trying to add target into button this way: btnAll.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside) But it is giving me an error: Use of unresolved identifier 'buttonTapped' But I declared function like: func…
Ram Mani
  • 1,009
  • 1
  • 10
  • 15
51
votes
4 answers

How do I write a for-loop in Swift 3 for an array that I modify during the for loop?

So, I have a for-loop that looks similar to this: for var i = 0; i < results.count ; i += 1 { if (results[i] < 5) { results.removeAtIndex(i) i -= 1 } } This used to work. But when I changed it to the preferred Swift 3.0…
JoeVictor
  • 1,806
  • 1
  • 17
  • 38
51
votes
5 answers

Swift 3 for loop with increment

How do I write the following in Swift3? for (f = first; f <= last; f += interval) { n += 1 } This is my own attempt for _ in 0.stride(to: last, by: interval) { n += 1 }
user462990
  • 5,472
  • 3
  • 33
  • 35
50
votes
4 answers

Using Swift 3 Stopping a scheduledTimer, Timer continue firing even if timer is nil

We call startTimer function to start a timer. When we wanted to stop it we call stopTimerTest function but after we called stopTimer function the timerTestAction keeps firing. To check the timer condition we used print and print in timerActionTest…
Hope
  • 2,096
  • 3
  • 23
  • 40
50
votes
1 answer

Strange Terminal Messages in Xcode 8

Recently, I have updated my Xcode version to 8. When I start and run an entirely new project, I get the following messages in my terminal. 2016-09-07 15:28:43.759998 App[7932:128675] subsystem: com.apple.UIKit, category: HIDEventFiltered,…
JacobSiegel
  • 5,311
  • 2
  • 14
  • 17
49
votes
13 answers

How to add PageControl inside UICollectionView Image Scrolling

I have UICollectionView Horizontal Image listing code. I want to add PageControl when scrolling images will shows, I added pagecontrol selector and IBOutlet but how can I integrate it between UICollecitonView? My code is below: class …
SwiftDeveloper
  • 7,244
  • 14
  • 56
  • 85
49
votes
5 answers

How to create managedObjectContext using Swift 3 in Xcode 8?

Facing issue "Value of type 'AppDelegate' has no member 'managedObjectContext' In new Xcode 8 (using Swift 3, iOS 10) when trying to create new context in View Controller let context = (UIApplication.shared().delegate as!…
Adelmaer
  • 2,209
  • 3
  • 22
  • 45
48
votes
5 answers

How to declare a 'protected' variable in swift

I want to create a class that inherits from another class, which is in a different file. For example: Class1.swift class Class1 { protected var //Do Stuff } Class2.swift class Class2:Class1 { //Do stuff } How would I be able to have…
iProgram
  • 6,057
  • 9
  • 39
  • 80
48
votes
1 answer

Can't Hide Status Bar—Swift 3,

I usually hide the status bar with override func prefersStatusBarHidden() -> Bool { return true } but Xcode is giving me an error, saying "Method does not override anything from its superclass". If I delete the override, Xcode gives a different…
owlswipe
  • 19,159
  • 9
  • 37
  • 82
48
votes
2 answers

preferredStatusBarStyle removed in Swift 3?

so I recently just updated to Xcode 8 and I just got this error for the following code. The error is that the method doesn't override any method from it's superclasses. override func preferredStatusBarStyle() -> UIStatusBarStyle { return…
Amit Kalra
  • 4,085
  • 6
  • 28
  • 44
48
votes
3 answers

Difficulties converting to Swift 3

After converting from Swift 2 to Swift 3 (even after converting edit-> convert -> to current swift syntax) I am getting lots of errors. Especially: I am shown total 90 errors for my project which was working fine in Swift 2 before i downloaded…
niravdesai21
  • 4,818
  • 3
  • 22
  • 33
48
votes
8 answers

Single line if statement in Swift

How would one convert the following to Swift from Objective-C? if (myVar) return; Swift does not use parentheses around the conditional, however the following code gives an error. if myVar return
BytesGuy
  • 4,097
  • 6
  • 36
  • 55
47
votes
1 answer

'CGAffineTransformIdentity' is unavailable in Swift

Came across this error when trying to do adapt some animations into Swift3 syntax. UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.8, options: [] , animations: { fromView.transform…
AMAN77
  • 6,218
  • 9
  • 45
  • 60
47
votes
5 answers

Objective-C Bridging Header not getting created with Xcode 8

I am trying to add objective-c libraries to my Swift 3 project (Xcode 8 IDE). But objective c interface header is not getting generated automatically. I tried to add bridging header manually but showing linking error saying bridging header .h is not…
Augustine P A
  • 5,008
  • 3
  • 35
  • 39