Linked Questions

60 votes
2 answers
16k views

Like many other developers I have been very excited about the new Swift language from Apple. Apple has claimed its speed is faster than Objective C and can be used to write operating system. And from ...
Penghe Geng's user avatar
97 votes
10 answers
49k views

Is there a way/software to give precise time needed to execute a block of code written in Swift, other than the following? let date_start = NSDate() // Code to be executed println("\(-date_start....
ielyamani's user avatar
  • 18.6k
35 votes
2 answers
5k views

As I was playing around with a swift tutorial, I started to write a custom isPrime method to check if a given Int is prime or not. After writing it I realized it was working properly but found it a ...
apouche's user avatar
  • 9,983
12 votes
8 answers
1k views

I have a long string (sometimes over 1000 characters) that I want to convert to an array of boolean values. And it needs to do this many times, very quickly. let input: String = "001" let output: [...
Alex Wayne's user avatar
  • 188k
10 votes
2 answers
3k views

Is there any quick way of evaluating the performance / runtime of a certain code part written in the new XCode 6 playground? I want to start learning Swift by comparing different coding styles for ...
AustrianDude's user avatar
13 votes
1 answer
6k views

I tried sorting an array of size 100000000 in Swift and Kotlin and i can see a huge performance gap between them. For this number, Kotlin is almost 18 times faster than Swift(on my machine). I ...
Kamran's user avatar
  • 15.3k
7 votes
4 answers
8k views

Suppose I have an array of dictionaries: [ { "id": 2 }, { "id": 59 }, { "id": 31 } ... ] How can I sort this so that it's in descending order, sorted by "id"? My initial approach is something like: ...
TIMEX's user avatar
  • 275k
3 votes
4 answers
5k views

I'm implementing what is essentially a cache using a Dictionary in Swift. The performance is well short of what I would expect. I've read some of the other questions, for example this one about array ...
Andy Wilkinson's user avatar
4 votes
1 answer
3k views

Several threads on stackoverflow (e.g. this one) discuss the different optimization levels (Onone, O, Ounchecked...) when compiling Swift applications. However, those postings are related to the ...
fxlae's user avatar
  • 905
2 votes
1 answer
813 views

I am having horrendous performance with Swift (low fps with only a few textures being drawn). In java on android I am executing the batch of code below between 30 and 40 times faster. I have some ...
NJGUY's user avatar
  • 2,095
0 votes
1 answer
275 views

I have code to solve a sudoku board using a recursive algorithm. The problem is that, when this code is run in Xcode, it solves the algorithm in 0.1 seconds, and when it is run in playgrounds, where ...
user avatar
2 votes
2 answers
144 views

Say I have and array [4, 1, 8, 5] and another array that corresponds to each object in the first array, say ["Four", "One", "Eight", "Five"]. How can I sort the first array in ascending order while ...
raginggoat's user avatar
  • 3,620
0 votes
2 answers
158 views

So lets say we have an array a = [20,50,100,200,500,1000] Generally speaking we could do for number in a { print(a) } if we wanted to check the entirety of a. How can you limit what indexes are ...
itzknockout's user avatar
-4 votes
1 answer
97 views

I was doing gps location by using CLLocation. When i press submit button and start the process to get the coordinate. However the locationManager being called multiple times. How can I get the value ...
user1219310's user avatar
1 vote
1 answer
57 views

I did some comparison here: https://github.com/itchingpixels/structs-vs-classes and it seems like inserting a struct into an array of structs is 10x slower than inserting a class to an array of ...
Mark Aron Szulyovszky's user avatar