The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [swift]

Swift is a multi-paradigm, compiled programming language developed by Apple for iOS and OS X development.

Filter by
Sorted by
Tagged with
1
vote
0answers
55 views

Design a system for renting digital movies/books

During an interview I was asked to do an OO design for a digital renting system for books/movies. This is the design that I came up with. My assumptions: When the customer has downloaded a list of ...
1
vote
0answers
205 views

Swift Throttler and Debouncer

I have a Throttler and Debouncer functions that I took from an unmaintained library. I added my own tests, but not sure if the ...
1
vote
0answers
28 views

Reducing force unwraps in CLI utility

This is a CLI utility for managing the allocation of investment. It's an exercise, don't take it too seriously. So the utility asks the user a series of questions about it's finances and suggests a ...
1
vote
1answer
96 views

Swift UITableViewCell class to show cameras, ratings for a car wash and other information

I have an UITableViewCell class that written in Swift. And it seems to me that I did it the wrong way. It works fine, but I want improve the code or refactor it somehow to make it look better. Any ...
1
vote
0answers
2k views

Swift/iOS component for label with clickable text buttons

So I'm creating a component based on UILabel, which I'm calling RichLabel. The main goal is to add support for clickable links (...
1
vote
0answers
885 views

Trimming a video, keeping quality

I am trimming an existing (stored in my gallery) video into smaller chunks; but I find the resulting video quality to be too degraded. ...
1
vote
0answers
20 views

ManuallyCompletableOperation for OperationQueue

Here is a very handy subclass of Operation that allows to do asynchronous tasks inside an OperationQueue: ...
1
vote
0answers
99 views

UIImageView Animation with duration change

I have an array of UIImages that I animating using UIImageView, and creates an effect of wave. the user have plus and minus ...
1
vote
0answers
1k views

Upload multiple photos to server

I am uploading an array of photos to the server (using Alamofire): ...
1
vote
0answers
191 views

Singleton lock for a queue

This is a singleton class which can be accessed anywhere including the shouldLock variable. I want to make sure that the variable is thread safe. Basically the <...
1
vote
0answers
74 views

Runtime function in Swift

I have the following case, I need to delete a specific observer for the firebase database reference, so I made a code that looks something like it looks to the ...
1
vote
0answers
310 views

Handler for a UI to select multiple days of the week for notifications

In the app I am currently working on, there is a part where user can set multiple local notifications for specific weekdays. The array of buttons is represented by a separate class, which utilises ...
1
vote
1answer
98 views

Large switch statement bucketing system

I've finally got a solution for a "weekly streak" bucketing system I've been working on but unfortunately it's resulted in a very large switch statement. I'm running through a handful of dates and ...
1
vote
0answers
59 views

Weight Lifting App to calculate a One Rep Maximum

I'd like feedback on the main entity in the Core Data model of my "One Rep Max" weightlifting calculator. All feedback is appreciated and in particular, I'd like to know if I've done a decent job of ...
1
vote
0answers
377 views

VIPER Architecture

I write Swift and architect apps mostly based on VIPER pattern. The thing I always wonder is, is it a proper to store some temporal values in Interactor? Let me ...
1
vote
0answers
823 views

RxSwift iOS Observable FIFO Queue Implementation in Swift 2

I am trying to develop an Observable queue that executes given Observable chains one at a time. The code will be used to encode videos on an iPhone and only one queue will be needed per launch, ...
1
vote
0answers
166 views

Multi-Context CoreData Implementation

I'm using Mulit-Context CoreData for Asynchronous Saving, which follows this architecture: Here is code stack: ...
1
vote
0answers
2k views

Paging loader using RxSwift

This is generic logic for handling network requests that load data based on pages. It is assumed that the view controller would implement the UISource protocol. I ...
1
vote
0answers
208 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 ...
1
vote
0answers
614 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: ...
1
vote
0answers
180 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-> ...
1
vote
0answers
37 views

Formatting data in a UIViewController in a weight-training app

I'm writing a weight training app that calculates a one rep maximum and it has several options including recording your lifts in pounds or kilograms. I'm trying my best to follow the MVC pattern but I'...
1
vote
0answers
2k views

A custom UIView with gradient fill, border, and variable corner radii

Here is a swift port of UIView subclass that I use often in my apps. It allows me to easily set gradients in place of the backgroundColor property, and also makes it very easy to create views that ...
1
vote
0answers
116 views

Calculating the tip and tax portions for a refund amount

refundableSale is a PMSale object with properties refundableTip, ...
1
vote
0answers
86 views

House cleaning calculator

I have a tableView holding an array of 4 items: ...
1
vote
0answers
627 views

Spawning nodes with random time interval in SpriteKit

I want to spawn objects with random time interval (from 1 to 3 seconds). I've wrote this function: ...
1
vote
0answers
65 views

Abstraction of NSNotification that removes the existing observer for a notification when a new observer is added

I ran into a problem in my app where under some conditions, a view controller might be loaded more than once before its deinit (where I was previously removing the observer) is ever called. So the ...
1
vote
0answers
761 views

Showing Or Hiding AdMob Banners - Purchased vs Not-Purchased IAP Banner Non-Consumable

I have the following code that displays a standard AdMob banner depending on whether the user has purchased an ad-free (banner-free) non-consumable In-App Purchase or not (i.e. If purchased, no ...
1
vote
0answers
41 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
vote
0answers
200 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 ...
1
vote
1answer
122 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? ...
1
vote
0answers
41 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 ...
1
vote
0answers
403 views

Adding a constraint to a PFQuery on a PFRelation with objects that have already been gotten

For some background, I am learning from the following Stack Overflow question that I asked regarding creating the this code. I was playing around with different combinations of ...
1
vote
1answer
1k views

Globally accessible helper class [closed]

I would like to get opinion if I am doing this right. I am creating a helper class that is globally accessible to my whole project. I want it to be easily called like ...
0
votes
1answer
242 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, ...
0
votes
2answers
158 views

Design a system for creating a coffeeshop menu

During an interview I was asked to design the menu for a coffee shop employee so that the employee would go and add different items to the menu. This is the design that I came up with. I just want ...
0
votes
1answer
223 views

Find common directory path

I answered the problem of Find common directory path from Rosetta Code. The problem consists of passing '/home/user1/tmp/coverage/test', ...
0
votes
1answer
11k views

Prevent a UITextField from being input with aphabetic characters

The goal is to disallow typing alphabetic characters as input in a UITextField. Please tell me if this approach is convenient. ...
0
votes
2answers
2k views

UIAlertController and input validation

I'm refactoring some "old" Swift code using deprecated UIAlertView and delegates. I have a UIAlertController with an input ...
0
votes
2answers
58 views

Calculating risk levels

Let's consider following function that return some risk levels enum type: ...
0
votes
1answer
124 views

Initiating Child ViewController from UIStoryBoard in iOS

I'm trying to use inheritance in UIViewController where base class has XIB in storyboard. I'm troubling with initiating different children classes with that XIB. I ...
0
votes
1answer
59 views

Change level button's image

There are 12 buttons, and each of them has 3 options for selecting pictures, depending on the data. It works but I think need a shorter and more intelligent decision. ...
0
votes
1answer
79 views

Efficiently structuring data with protocol oriented approach in Swift

I need to integrate some server API calling in which I'm likely to get response as: ...
0
votes
1answer
332 views

Simple networking layer in Swift using Strategy design pattern

Does the following code demonstrate proper use of Strategy design pattern for a simple networking layer in swift 3? Some code smells I'm unsure about: violates Single responsibiility principle. ...
0
votes
1answer
63 views

Parser to extract calendar data

I'm wondering how I can improve this class, for instance: Should local variables such as allInput that are passed in to more than one function be instance ...
0
votes
1answer
156 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 ...
0
votes
1answer
109 views

Extract regex matches with non matching parts

I want to check a string by using multiple search patterns and split the string at every occurrence. I'm using RegEx and it works fine. But I'm worrying about efficiency and performance. ...
0
votes
1answer
3k views

Calling a method only once in an updateScore function in SpriteKit

This works fine, but obviously it's messy and I'm thinking there has to be a better way to do this. Having to constantly remember to flip the bool back is a pain, is there anything else I can do here? ...
0
votes
1answer
2k 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
22 views

Test A Swizzling Swift method

I've a method that swizzles out the the localization bundle for another put in the project build. It works great: ...