Swift is a multi-paradigm, compiled programming language developed by Apple for iOS and OS X development.
1
vote
0answers
24 views
Workout tracker and performance analyzer app
With this iOS app, the user can create workouts (e.g., Squat, Bench Press, etc) and then track their progress including current weight and number of weights. Performance calculations are also ...
-1
votes
0answers
26 views
Creating a custom view ios [on hold]
I have created a custom bar button item.
It works correctly in the simulator . I would like to know if this is the correct way of creating custom views.
...
0
votes
1answer
12 views
Singleton manager/service classes with mockable dependencies in swift
In our swift project, there are multiple service classes that encapsulate functions, mostly network-api calls. They implement a protocol, and depend on other service classes, e.g. an authorization ...
0
votes
0answers
14 views
Class property holds data from database
I have a class, it has two properties:
var fruitsPackId: Int
var fruitsPackContent: Array<Fruit>?
Once the class is ...
0
votes
0answers
40 views
Fullscreen overlay NSWindow using constrainFrameRect(_:toScreen:)
A project I'm working on requires a fullscreen overlay NSWindow that must be trusted to stay fullscreen no matter what. Rather than subscribing to
...
3
votes
0answers
61 views
Unit Testing Against Exceptions
I am writing a Swift library. I'm writing unit tests for that library.
I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can ...
5
votes
1answer
34 views
Vertical-scrolling 2D platform game
I am working on a vertical-scrolling 2D platform game using GameplayKit, SpriteKit and I am writing it in Swift 2.0.
Today I ...
1
vote
2answers
90 views
Intersect two ranges in Swift
Can you think of a reason the following extension should not be used in production, or a better way of implementing it:
...
1
vote
0answers
36 views
Design Patterns in Swift: Visitor
I'm solving the following problem using the Visitor design pattern in Swift:
When a quote is requested or an appointment is booked we send out an
email to the customer, and build an internal ...
0
votes
0answers
13 views
Design Patterns in Swift: Strategy
I'm solving the following problem using the Strategy design pattern in Swift:
We order our parts from three different vendors. Each vendor has its
own system for verifying and fulfilling parts ...
2
votes
2answers
58 views
Design Patterns in Swift: Mediator
I'm solving the following problem using the Mediator design pattern in Swift:
Assume we track the location of all our mobile mechanics. We have
noticed that there are times when a mobile ...
2
votes
1answer
30 views
Design Patterns in Swift: Chain of Responsibility
I'm solving the following problem using the Chain Of Responsibility design pattern in Swift:
Not all mechanics are created equally. Some mechanics are more
experienced and can do more than ...
5
votes
2answers
56 views
Time manipulation for notification reminders
I'm new to programming, Stack Overflow and Code Review. I was encouraged to post this method here based on a question I posted on StackOverflow here. Let me know if you have tips for improving this ...
3
votes
1answer
44 views
Observer design pattern in Swift
The problem:
We have a set of mobile mechanics who are assigned specific zip codes. Each zip code has its own hourly rate. We want to increase and decrease these rates when the number of idle ...
2
votes
1answer
42 views
Extending UITableViewCell to preserve UIView background color when selecting the cell
When a UITableViewCell has subviews with background color set, when setSelected(_: animated:) gets called, all the views are ...
3
votes
1answer
92 views
Fixed-length Sequences in Swift 2.2
The following is an implementation of fixed-length sequences that makes very exotic (and hopefully fun) use of Swift 2.2 types. The question is what exactly is the cost of having the type checker ...
0
votes
1answer
39 views
Factory pattern for image or shape marker [closed]
I'm making a photo marker application and need to make a factory pattern for marker. I think it is not very flexible and overall not good.
Would you check my code and suggest what could be improved?
...
3
votes
0answers
98 views
A general iterator to replace “non-standard” C-style for loops
Since the deprecation of C-style for loops in Swift 2.2 (and the removal in Swift 3),
several questions about the possible replacements were asked on Stack Overflow. In most cases, a ...
4
votes
1answer
41 views
Classification tree in Swift
As an effort to teach myself Swift as well as to get familiar with machine learning algorithms, I've been trying to implement common algorithms, starting with a Random Forest. This is, for the moment ...
0
votes
0answers
20 views
Filter option for PFQueryTableViewController in Swift
I have a PFQueryTableViewController, and have create a separate TableViewController that allows me to select a filter option. When the user selects an option to ...
6
votes
0answers
44 views
Adapting layout for various iPhone and iPad screens using constraints and multipliers
My experience with autolayout tells me that it's very difficult to make app look good on whole variety of devices (from iPhone 4s to 6s especially). Size classes are useful with device position and ...
3
votes
1answer
51 views
Tracking a geolocation
I have created this ViewController using Swift. Its job is to track geolocation and draw a line on a map and save it to core data object. I just want some advice on ...
0
votes
1answer
46 views
Stanford developing calculator iOS app assignment
I'm currently learning Swift by following the Stanford developing iOS app 2015 lecture series. I have completed assignment 1 but am wondering if there is any improvement can be made to my code.
Also, ...
1
vote
1answer
31 views
UICollectionView button target
Within my app i have a UIButton (avatar button which shows a profileVC) within a UICollectionView this button shows up in about ...
2
votes
1answer
33 views
XCTestCase#waitFalseExpectationUntilTimeout implementation
I am working on an iOS project and I'm in charge of testing most parts of it. As I write some tests, I often have the need to wait for an asynchronous method to finish, and then test that something ...
6
votes
1answer
86 views
iOS delegation design pattern
I am working on a project that has a Model-View-Presenter structure and use the delegation design pattern that has the following structure/implementation. I would love feedback.
The ViewController ...
2
votes
2answers
131 views
Music player in Swift
I made a simple mp3 player that plays, pauses and stops a given song, shows the time elapsed, and has a volume control. I read the documentation and can't figure out the difference between the ...
1
vote
2answers
42 views
Anchor Text String Transformation in Swift
I need to convert a string using these rules:
Downcase the string
Replace spaces, a blacklist of "invalid" chars, and non-ascii letters (like é) with -
Replace ...
5
votes
1answer
688 views
Dot product, ported from C to Swift
This is how I posted a method from C to Swift. I tested it well, it seems to work. It's there a way to write this better, following good practices of Swift? The original is in C and the target must be ...
9
votes
1answer
91 views
Portfolio object made of Asset classes and Securities
I am learning Swift and object oriented programming. I am new to design patterns and protocol oriented programming.
In my test code I have several related objects:
...
9
votes
2answers
214 views
Swift replacement for C's for-loop
I recently wrote an entry on my blog regarding unit testing using prime numbers as an example.
When I wrote the entry, I wrote my code keeping in minding that proposal SE-0007 has been accepted for ...
1
vote
1answer
67 views
Simple Text Prediction
This is a simple implementation of text prediction using a list of keywords and UITextChecker.
This is working correctly, but I think I could have implemented ...
6
votes
1answer
83 views
Reading bytes from packet
I have a device I connect to on TCP socket. I send it a message with what I want and it sends back all sorts of useful information:
Header:
...
3
votes
1answer
66 views
Using an Edit box in a table views header section to insert the values into the table using swift
Allow me to provide some context. I have a UITableViewCell that contains an EditText and a Button. This cell is then inserted into the ...
5
votes
2answers
173 views
Tic Tac Toe in Swift
Any feedback encouraged. My checkForWinner function feels cumbersome to me.
...
2
votes
1answer
51 views
Loading images in the background for a table view
I have fetchData method which fills my imagesArray:
...
4
votes
1answer
75 views
Swift menu code
I want to know what do you think about the structure of this code. If you think that there is some structural improvement to be made, tell me!
Here is a github link: ...
-2
votes
1answer
35 views
improving parser code
In a toy language I wrote (very LISP-like), the most inelegant part is the parsing.
The language is organized as one class per programming construct, each class with its own parsing method. If the ...
2
votes
1answer
132 views
Image Scrolling in UITableView with Parse
I'm trying to create an app that is scalable. One of the main features of the app is to view images from a database to a UITableView. Here is my code:
...
3
votes
0answers
274 views
Caching image in memory or on disk
I am caching an image locally..That same image will be used in few screens. Steps for doing this is as follows:
Get image from cache
If not present in NSCache, get image from Cache directory
If not ...
2
votes
1answer
55 views
Ignore nil values and unwrap optionals returning the value as the wrapped type
My primary concern is that this has been written as a global function. I think it would be better if this was a function of the SignalProducer class but I am not ...
6
votes
3answers
129 views
Loading Configurations from plist into singleton
In my iOS application, I've created a singleton class that reads a configuration plist file and provides accessor methods to easily retrieve the values:
...
5
votes
2answers
495 views
Type to byte array conversion in Swift
I need the byte representation of a given type, especially double, float, int8, etc.
...
11
votes
1answer
179 views
Secret Santa with Groups on Swift
I am working on an special version of Secret Santa with internal sub-groups.
Typical Secret Santa (SS) requirements:
Cannot be assigned to themselves
Should be random
Every participant should be ...
6
votes
1answer
326 views
UICollectionView image gallery app
I built an app that allows users to add and remove images in a collection view. I want this to be useful online so I save the images into a database and retrieve them every time. I'm looking for ...
8
votes
2answers
169 views
C hack: replace printf to collect output and return complete string by using a line buffer
I have this great C program I'd like to embed into an iOS app. One passes command line arguments to it and the results are printed to stdout via ...
2
votes
0answers
70 views
Am I using ReactiveCocoa the “right” or most “purely functional” way in this Document class?
Introduction
I am still learning both swift and ReactiveCocoa, and instead of directly applying it to one of my projects, I have instead worked a few hours on ...
5
votes
1answer
175 views
Weighted Probability Problem in Swift
I was asked a weighted probability question in a technical interview a few months ago that went something like this:
Given an input of colors and an integer "weight" value, randomly return a color ...
4
votes
1answer
123 views
Optimize Data Sending/Querying to Parse Swift iOS
I have a swift method that I'm using to update Parse in the backend when the button is tapped. Votes are being updated: The method acts as a voting system, incrementing a label every time it's tapped. ...
4
votes
1answer
201 views
Updating number of votes with a “Like” button
I have a "Like" button in my iOS app that updates the votes every time it's tapped. Just like Facebook, Instagram, ProductHunt, etc.
I have a custom cell where that ...