Swift is a multi-paradigm, compiled programming language developed by Apple for iOS and OS X development.
4
votes
0answers
21 views
Sequence-based enumeration of permutations in lexicographic order
This is follow-up on
On Knuth's "Algorithm L" to generate permutations in lexicographic order,
where I presented the following method to enumerate all permutations of array elements
in ...
3
votes
0answers
30 views
On Knuth's “Algorithm L” to generate permutations in lexicographic order
I needed a method to generate all permutations of given elements, so I decided to
implement "Algorithm L (Lexicographic permutation generation)" from
Donald E. Knuth, "GENERATING ALL PERMUTATIONS"
in ...
-4
votes
0answers
18 views
How can i parse json in my uicolectionview swift3? [on hold]
can somebody please tell me what is wrong with my code? how to show from son in UILabel i UIColeectionView?
Model.swift
...
4
votes
1answer
35 views
UIButton subclass with animated 'shimmer' effect
In earlier versions of iOS the lock screen had a 'slide to unlock' element which I'm referencing as a 'shimmer' effect.
The effect I'm looking for is simpler:
Button starts with single color (e.g. ...
6
votes
2answers
142 views
Practical number algorithm
I am trying to write a program to find the practical numbers, from an input from \$1\$ to \$n\$.
Practical numbers
My code is running correctly but it is extremely slow when calculating numbers ...
2
votes
0answers
47 views
REST API client
I am new in iOS development and Swift. I am going to develop a simple application which communicates with external REST services. This is my first experiment.
I appreciate feedback on best ...
2
votes
1answer
45 views
3
votes
2answers
86 views
Loading data from a web API to be displayed in a tableview
In my object Dish xxx.Dish, I want to access the Choice class price and name to display . ...
4
votes
1answer
63 views
Swift 3 UIPicker
I have been making a little test app to try and learn Swift 3 / iOS better. I started a while ago with with Swift 2 but stopped, so getting back into it, but there is so much iOS to learn!
Just ...
7
votes
4answers
861 views
Project Euler problem 14 (longest Collatz sequence) in Swift 3
I was trying to solve Project Euler:Problem 14 using Swift 3, but it takes ages to give me an answer, which is a sign that my code is absolute garbage performance-wise. What could I do to increase the ...
1
vote
0answers
38 views
Amplitude and Frequencies of sound Analyser
As I'm beginner with mobile/OO programming, I reached a situation that confused me and made me wonder if I was coding correctly...
The main class:
...
0
votes
0answers
6 views
In regard of memory consumption: Why choose static let over (computed) static var? [migrated]
My project has grown and so have my extensions with utility methods to access certain types. I have an extension for UINib for example that looks like this:
...
2
votes
1answer
91 views
Generic array flattening function
With help from the codereview community, I've written a function to flatten a generic nested array. I have it written several ways but want to focus on the following implementation:
...
1
vote
1answer
70 views
CommandLine StreamFormatTester
Using Chris Adamson's book Learning Core Audio I'm getting familiar with Core Audio for Mac/iOS. The code examples are 100% Objective-C. I'm trying to follow along using Swift 3.
This small piece of ...
3
votes
2answers
80 views
Swift HackerRank Missing Numbers Challenge
I'm attempting to solve the "Missing Numbers" challenge on HackerRank where I'm tasked with finding missing elements comparing two arrays.
Foundation's ...
2
votes
0answers
29 views
A most convenient way of comunicating between views and a view controller in Swift [closed]
I have a few nibs, call it Container and Element. So I have classes for both nibs:
...
1
vote
0answers
34 views
Cookie Clicker esque game idea
I am making a cookie clicker type game as a small project, within Xcode, written in Swift. I have a been developing a function which will turn a Int64() into a 4 ...
3
votes
1answer
52 views
Extract index of first unique element in large array in Swift
I'm using the following code to return the first index of a unique character in a large String. It works fine until I get to large strings, where it times out.
Is ...
3
votes
1answer
102 views
Remove Duplicates from Array in Swift 3.0
I ran the following code through a Leetcode.com challenge and it says the runtime for the test cases is 119ms, which puts it at the back of the pack performance wise.
The goal is to remove duplicates ...
1
vote
0answers
15 views
Why is my countLBl not changing [closed]
@IBOutlet weak var textTxt: UITextView!
@IBOutlet weak var countLbl: UILabel!
...
1
vote
1answer
68 views
Showing segue after button action
I have an iOS Swift app with 8 buttons that call the same segue, but this is very repetitive. How can I refactor so it uses the same function prepare?
...
8
votes
6answers
1k views
DFT (Discrete Fourier Transform) Algorithm in Swift
I am looking to replicate in Swift what the FFT function does in Matlab. Essentially, it takes an arbitrary length signal (not necessarily a multiple of \$2^n\$) and gives real and complex DFT ...
2
votes
1answer
71 views
0
votes
0answers
48 views
Mocking protocol with class/static functions in Swift
I am using one of the open-source Objective-C keychain wrappers to store data in iOS keychain.
For test cases, I have created protocol as:
...
0
votes
0answers
77 views
Filtering two attributes using Firebase
I have a game data structure in Firebase that looks like this..
I have a view controller in my app that loads up all the games for a specific team. I have the following code which works.
...
4
votes
2answers
154 views
Parsing and converting DMS Coordinates from String to Double
I have some coordinates looking like
N47° 15' 36.75",E011° 20' 38.28",+001906.00
and I've created a class to parse and convert them to Double:
...
7
votes
1answer
102 views
Mocking UserDefaults in Swift
In my application, I am using UserDefaults to save some data.
I also started writing tests for testing my application code.
At one place I stuck where I wanted to ...
6
votes
2answers
115 views
Project Euler solution #2 using Swift 3
I just wanted some review and opinions. Any better implementations or suggestions would be great.
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting ...
5
votes
0answers
89 views
Swift class to check ApplePencil reachability
I've implemented a class that lets you check out whether there is an ApplePencil connected to the device or not.
...
1
vote
0answers
29 views
XMPP XML Parsing and Tests in Swift
I am implementing chat app using XMPP.
Here is my XML Parser function which tells me whether given XML is file transfer offer or not:
XMPPIQ+FileTransfer Extension->
...
0
votes
0answers
31 views
Simple tapping game in SpriteKit
I wrote this as an answer for someone in SO. After writing it I realized it looked pretty good, and was wondering if anyone else thought so as well--or if there were any general improvements to ...
2
votes
0answers
45 views
Posting iOS notifications from sender or from receiver
In Swift, should I be posting notifications to the iOS notification center from the device sending a text message or from the device receiving it?
I'm using ...
0
votes
1answer
214 views
iOS Core Data Model with Swifty JSON
I have been using SwiftyJSON to create my models of Object in Swift.
But recently, I moved to CoreData for saving the objects locally.
I am new to CoreData and want to know the best practices I should ...
3
votes
1answer
108 views
Singleton class with custom initializer
In a Swift project, I have a class should be used as a singleton:
...
2
votes
1answer
77 views
Setting constraints for dynamic views in iOS
I have an app which uses Stack Views to update its UI depending on the number of pigs. For example below, 1 pig and 4 pigs.
I set up Stack Views in Storyboard and set isHidden to true based on how ...
2
votes
2answers
79 views
Property value from an asynchronous operation
I have an app which has a session mechanism. When a user creates an account in the app initially, the API returns an access token, the expiry date of that access token and a refresh token which can be ...
-5
votes
1answer
109 views
How can I clean my swift code [closed]
Here is my code . I am not sure is it best practice or not? Please help me to clean my code. I initial all value. Should O put all in optional ?. Is there any ...
1
vote
1answer
93 views
Allow UITextView to resize as the user is typing
I want to be sure that in terms of auto-layout or just following the proper methods of doing the following is acceptable. I am not sure if there will be an constraint issues or efficiency problems ...
1
vote
1answer
315 views
Find substring of a string in Swift 3
I am using this basic extension for a Swift project. It works well, but I want to make sure it is the absolute fastest way to get a substring.
...
0
votes
1answer
49 views
Simple HTTP API requests in an exam paper download app
So basically I am building an app that helps to download some documents via a rest api.
Here is the SearchViewController
...
3
votes
1answer
69 views
Simple War game in Swift
I'm new to swift and I want to know if I'm doing something wrong or a harder way. I made a simple war game app. Tames of variables aren't correct, I know, but I was doing it quickly and I didn't worry ...
1
vote
1answer
93 views
Flexible String tokenization in Swift
I want a flexible and fast way to break a string up into strongly typed tokens so that I can do things like the following:
...
3
votes
0answers
25 views
Comments on a 'PullableView'
I created a view called PullView which adds a level of interactivity to UI components. PullViews can be pulled sort of like a ...
1
vote
2answers
185 views
Showing activity indicator (loading image) while processing in background
I have a login screen on my iOS app. When I click login button I want to make sure that user should be displayed a loading image in center of the screen.
I found lots of different methods online but ...
4
votes
1answer
98 views
Search a string for barcodes but ignore certain characters
I had to write a string search function that would search for barcodes, and be forgiving of minor formatting differences. For example, the barcode may be entered as ...
3
votes
1answer
57 views
Optimal custom operator with generic type constraint for numerical type
I'm implementing (for an article) two custom infix operators:
¿% - to calculate percent of total
%? - to calculate the percent ...
1
vote
1answer
74 views
Configure Table cell in model class
I'm trying to show data in UITablleView after getting it from an HTTP request. I heard that the best and professional way to do it is configure the cell and do the ...
3
votes
1answer
63 views
Transformations an array, combination of between map and reduce
I'm working on a function that reduces pairs of elements if they meet some criteria.
For example, given an array: ["1", "2", "a", "b", "3", "4"] I want to ...
0
votes
0answers
99 views
4
votes
2answers
798 views
Basic calculator in Swift 3
I just started learning the basics to Swift 3 about 2 days ago. Since then, I've decided to make a simple calculator that can only do one operation at a time.
I was wondering how efficient this was ...