Swift

Swift is a general-purpose, open-source programming language developed by Apple Inc. for their platforms and Linux. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [osx], [watch-os], [tvos], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

61 votes
17 answers
437 views
How do I see which version of Swift I'm using?

I just created a new Swift project within Xcode. I am wondering which version of Swift it's using. How

avatar
Margo
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
2.8K views
iOS 8 UITableView separator inset 0 not working

I have an app where the UITableView's separator inset is set to custom values - Right 0, Left 0. This wor

avatar
Trudy
0 1 0 9
asked 07 September, 2021
55 votes
23 answers
2.9K views
@selector() in Swift?

I'm trying to create an NSTimer in Swift but I'm having some trouble. NSTimer(timeInterval: 1, targ

avatar
Majorie
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
1.9K views
Split a String into an array in Swift?

Say I have a string here: var fullName: String = "First Last" I want to split the string base on white spac

avatar
Sena
0 1 0 9
asked 07 September, 2021
61 votes
30 answers
2.5K views
Get the length of a String

How do you get the length of a String? For example, I have a variable defined like: var test1: String = "Scot

avatar
Forrest
0 1 0 9
asked 07 September, 2021
51 votes
17 answers
2.3K views
#ifdef replacement in the Swift language

In C/C++/Objective C you can define a macro using compiler preprocessors. Moreover, you can include/exclude so

avatar
Rufus
0 1 0 9
asked 07 September, 2021
56 votes
16 answers
1.2K views
How to iterate a loop with index and element in Swift

Is there a function that I can use to iterate over an array and have both index and element, like Python'

avatar
Keith
0 1 0 9
asked 07 September, 2021
51 votes
9 answers
2.7K views
Swift Beta performance: sorting arrays

I was implementing an algorithm in Swift Beta and noticed that the performance was very poor. After digging de

avatar
Basil
0 1 0 9
asked 07 September, 2021
55 votes
20 answers
1.8K views
#pragma mark in Swift?

In Objective C, I can use #pragma mark to mark sections of my code in the symbol navigator. Since this is a C

avatar
Don
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
1.1K views
How to change Status Bar text color in iOS

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anyt

avatar
Bryan
0 1 0 9
asked 07 September, 2021
58 votes
17 answers
778 views
How do I call Objective-C code from Swift?

In Swift, how does one call Objective-C code? Apple mentioned that they could co-exist in one application, bu

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
713 views
Passing data between view controllers

I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following: I have a

avatar
Vi
0 1 0 9
asked 07 September, 2021