Swift is a multi-paradigm, compiled programming language developed by Apple for iOS and OS X development.
0
votes
0answers
3 views
Project Euler #10 in Swift - Summation of primes
I just finished Project Euler #10 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
I hope I learned some from ...
2
votes
1answer
24 views
Project Euler #9 in Swift - Special Pythagorean triplet
I just finished Project Euler #9 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
A Pythagorean triplet is a ...
2
votes
2answers
47 views
Project Euler #8 - Largest product in a series
I just finished Project Euler #8 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
The four adjacent digits in ...
4
votes
1answer
52 views
Swift project using PHP web service
I was hoping for someone to review my current project, which was created in Swift and uses a PHP web service. I'm not worried about UI elements, as this is just a 'test' project, but I'm concerned ...
4
votes
2answers
81 views
Project Euler #7 - 10001st prime
I just finished Project Euler #7 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
By listing the first six ...
4
votes
1answer
88 views
Closure as UIControlEvents handler
I'm expanding the functionality of this SO answer.
Mainly I'm focusing on:
You can add as many handlers as you want.
You can remove (i.e. cancel) the handler.
You can receive the ...
2
votes
1answer
69 views
Finding matching Node instances in an array - running slow
I have encountered a performance issue in Swift. I compared the same method between C# and Swift: Swift is much slower than C#.
Here is the code I'm working with. Could some one help me to speed it ...
6
votes
1answer
87 views
Performance of A* route
I'm new to the Swift language. I have a C# version of a simple A* route which is very fast. But I rewrote it with Swift, and the performance is very bad (3,4 seconds for a very simple road).
Could ...
3
votes
1answer
148 views
Pure Swift solution for socket programming
I have spend quite some time now to find out how exactly to do socket programming in Swift (Xcode 6.1). There are a few examples out there, but most of them no longer work for the latest release of ...
6
votes
0answers
60 views
Let's play some Swift Poker
Before you can do any sort of card game, you must first write some code to define your deck of cards.
One thing I've noticed in looking at some of Apple's Swift interfaces is that they very much so ...
2
votes
0answers
62 views
Usage of MVVM in iOS [closed]
I'm an iOS developer and I'm guilty of having Massive View Controllers in my projects so I've been searching for a better way to structure my projects and came across the MVVM (Model-View-ViewModel) ...
2
votes
1answer
80 views
Subclass SKSpriteNode
I decided to subclass SKSpriteNode for a game test in Swift today and soon realised that it was not as simple as my Objective-C background suggested. After a little ...
2
votes
2answers
97 views
Swift complexities with Dictionary
I have been trying to learn the various aspects of the languages I know so far to do the Daily Challenges in reddit (/r/DailyProgrammer). The one which I am working on just now asks for an ...
1
vote
0answers
77 views
Filling a cumulative array in Swift
I have a "cumulative" lookup array for a custom collection view layout.
The idea is that I have an array of rectangles, each with an index. The index is not unique, and is monotonically increasing. ...
10
votes
1answer
248 views
IBDesignable UICheckbox
One UI control that has always been mysteriously missing from Xcode's interface builder is some sort of checkbox. UISwitch is available, but this isn't always ...
7
votes
2answers
129 views
Defining a simple function-calling operator
I have been writing Swift code for a while and have read a lot of tutorials about how functional paradigms can be applied to Swift.
I defined a simple operator:
...
7
votes
2answers
104 views
Swift error handler for HomeKit
I have this universal error handler for my HomeKit app (currently in development). It grew out of wanting a single place to write error messages, show alerts, etc. I wanted a short, simple way to call ...
10
votes
1answer
768 views
Piano app in Swift
I'm making my first app in Swift: a Piano app. I'd like to get your feedback especially about how I can make codes shorter. I maybe have to use arrays and loops and something, and searched by myself ...
6
votes
1answer
110 views
Slowdown when swapping between views
I am working on a project called neoCode that takes a users input URL and turns it into HTML or Machine Code. I am so close to pushing this to TestFlight for beta testing but I have a pretty bad ...
5
votes
1answer
307 views
Road to MVC: the case of Settings Table View Controller
Now that I know that MVC can help do better code, I want to make my SettingsTableViewController class conform to it.
...
13
votes
1answer
3k views
Rewrite code from Objective-C to conform with Swift power tools and concise style
I started a project with Objective-C and rewrote it with Swift. The project contains two UITableViewControllers: MasterViewController and DetailViewController. ...
4
votes
1answer
130 views
3
votes
1answer
223 views
Images viewer from URLs with download progress
I've created an imageViewer that will be initialized with a String array, and will download and show the images as needed.
Alongside a review, could you give me a ...
4
votes
0answers
138 views
Asynchronous Array.map
I put together an asynchronous map function for Swift's Array using Grand Central Dispatch. It's called with a transform ...
6
votes
1answer
602 views
Updating the UI with a timer - code intended to help teach
I thought it would be helpful to put together an example of what I'm talking about in the second part of my answer to this stackoverflow question.
The idea is that there's some data that is updated ...
5
votes
1answer
112 views
Project Euler #5 (Smallest multiple) in Swift
I found this one a little bit easier than the previous problems, but I was already familiar with the GCD/LCM formulas.
...
2
votes
1answer
307 views
UISegmentedControl with view-animation
I have create a UISegmentedControl and a view under it. The view under contains all a view for each segment. I am doing an animation when the segment is changing.
...
10
votes
2answers
732 views
Project Euler #4 (largest palindrome product) in Swift
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two ...
7
votes
2answers
221 views
Project Euler #3 (Largest prime factor) in Swift
As mentioned in Project Euler #2 in Swift, I intend to work my way through Project Euler using Swift to make sure there aren't any tricks I'm missing.
This is the problem statement for #3:
The ...
11
votes
4answers
845 views
Project Euler #2 (Even Fibonacci numbers) in Swift
I figured working through Project Euler problems in Swift would be a good way to learn any tips or tricks. For example, tuples are something I'm not used to using, but they proved useful here. Using ...
5
votes
1answer
87 views
Showing a certain screen depending on a particular status
In this iOS app I'm working on, there are two landing screens shown to the user depending on a particular status. The screens are Login screen and Activate screen.
Let me explain what this Activate ...
14
votes
4answers
132 views
Int extension for translating integer to plain English
This code was inspired by this question: Number to Words
...
5
votes
1answer
229 views
Usability of this Observable class
I created an Observable class that allows me to subscribe to a wrapped value. The implementation looks like this:
...
4
votes
1answer
161 views
Counting the total value of Card instances given
I am trying to write a function called countHand() that takes in an array of Card instances and counts the total value of the ...
5
votes
1answer
226 views
Calculating delta in SpriteKit using Swift
I am attempting to learn swift by refactoring one of my old games and I need to rewrite my update method which calculates a delta time. This code works but is ugly. ...
8
votes
1answer
281 views
13
votes
5answers
1k views
7
votes
2answers
3k views
Is this a correct use of using protocols and delegate pattern in Swift?
I am trying to grasp the concept of delegates and protocols in Swift. So I have implemented my own PlayableMedia protocol with two concrete classes ...
10
votes
1answer
457 views
Swift string multiplication
I like Ruby's string multiplication so I thought I'd see if I could do it in Swift. I came up with these implementations:
...
8
votes
1answer
286 views
Storing global styles and utilizing them throughout view controllers
Assuming an app has many display styles, fonts, colors, etc., and that we never want to hardcode values, I've created an AppVariables object that houses properties ...
6
votes
1answer
259 views
RSS feed parser
I've just started learning Swift. I started with an example of RSS feed parser. I have a wrapper class written in Objective-C which converted the XML response into ...