Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [swift]

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

0
votes
0answers
8 views

MacOS Printing and Settings

I'm a Windows dev tasked with creating an app on MacOS. It's a favor for one of the nuns at my kids school. In this function, I need to print an image file. The first time I want to show the printer ...
1
vote
0answers
26 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 ...
0
votes
0answers
20 views

Integrate Google Map in Swift [closed]

I'm trying to integrate Google Map in swift, I've used following code for integration and result is shown in the screenshot. I've already installed the Cocoapods for google map, I've followed this ...
2
votes
1answer
48 views

Finding valid path on 2D Grid

I got a 2D grid (n x n matrix). The user selects his player in this 2D grid and after that selects another node in this grid to mark his destination position. The player is allowed to move ...
0
votes
1answer
25 views

Swift append an array when it's been declared as Any

I'm learning Swift and I have a following problem: I create a dictionary containing some data, one of which is stored as an array. I want make an operation on this array to add some info. Currently I ...
0
votes
2answers
108 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 ...
2
votes
1answer
41 views

How can this swift, firebase image fetching, function be made more concise?

I am trying to fetch a group of images within a place in Firebase database ref. I then loop through each image adding it to an array which is then supposed to be added to a tableview cell. I was ...
0
votes
0answers
32 views

Command line matrix effect in swift

I have modified a small swift package to reproduce the matrix effect on the command line, however I have been getting some weird characters. How do I limit the characters to be used in the effect? <...
1
vote
1answer
109 views

Stack using Linked List in Swift

I made this implementation of a stack in Swift that stores its elements as a linked list. It seems to work perfectly well, but I’m wondering how I can improve it to follow the best practices of the ...
1
vote
0answers
61 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
1answer
78 views

Caesar encryption and decryption

For a small project, I had to implement Caesar encryption in Swift(4). I'm mainly looking for performance optimizations. This whole code should be copy and pasteable in a playground and is ...
1
vote
2answers
85 views

Converting a String to USD

I'm working on a clientside iOS app for my school that involves students purchasing things, and I wrote a String extension for formatting a ...
1
vote
0answers
27 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 ...
2
votes
1answer
69 views

Manage Game Level with enum

Basically What I have is basket ball App. In which I have Added some levels and difficulties. logic is simply use tupple in enum and I have some methods to update / get current level with new values ...
0
votes
1answer
81 views

Creating an Enum with a Custom Type in Swift 4.x

I was in a code review today and someone said, "Why don't you do an enum on that?" I had started to, but conforming to a bunch of protocols seemed like a gigantic ...
1
vote
2answers
128 views

Form for OTP entry with six single-character text fields

I am working on an app in which I have to pass 6 digits OTP through 6 textFields in which you to provide only one character and after that it automatically goes to ...
1
vote
0answers
39 views

Probability shooting game

I've been working on this probability game that has a gun with 5/6 bullets. When there's a dodge the game removes a bullet and then the game continues, the goal being to get to 0 bullets. I don't use ...
2
votes
2answers
116 views

Finding a word that represents an image

This is an app wherein you have to find the word that represents the image. It's the same concept as the course app but I did this one myself. How can I improve this code (put more commentary, put ...
0
votes
0answers
39 views

Two different blocks with reverse direction in single method in Swift

So I've been trying to refactor my existing code for loading data from server and synching it to the local DB. Initially there were multiple methods with duplicated pattern, then I refactored them ...
2
votes
1answer
119 views

Swift - Finding longest binary gap of a given integer

I recently had the chance to try Codility's algorithm training, and the very first one in the list is finding the longest binary gap of a given integer. I tried to implement this in Swift, and after ...
2
votes
2answers
162 views

Sequence-based enumeration of permutations with Heap's algorithm

Heap's algorithm is an algorithm to generate all permutations of a given array. It ... generates each permutation from the previous one by interchanging a single pair of elements; the other n−2 ...
3
votes
1answer
50 views

Dividing an arbitrary dollar amount into the fewest bills and coins

I am taking a class in mobile application development this fall. I have finished my first assignment of creating a class to divide an arbitrary dollar amount into the minimum number of bills and coins....
0
votes
0answers
16 views

FilterOnTrigger Operator

Any constructive critiques on this operator is appropriated. This could be used, for e.g., to allow a stream to flow only when a UISwitch is set to on. (The switch's value producer would be the ...
0
votes
1answer
37 views

Tableview Subclass implementing delegate datasource

I have two view controllers which have same tableview. One is for Post and one is for Profile, which also contains a post by a user. I have decided to reuse the code, so I have created the class ...
1
vote
1answer
68 views

Closure implementation

I have custom cell of tableview which is used as header as well as normal cell. In custom cell I have this properties ...
4
votes
1answer
123 views

“What To Do” App

I am starting to build up my portfolio, so I am starting to build projects whenever an idea pops up in my head. So, I decided to build an app that helps you decide what to do. Basically how it works ...
3
votes
1answer
82 views

Presenting and passing data to a modal view controller without using prepare(for:sender:) method

I am using a toolbar button to present a modal view controller (in which I let the user export data as a PDF file). The main section of my app is a ...
0
votes
1answer
36 views

Damage or Heal based on the buttons you press

If you press the damage button, it will damage armor before health. If you press the heal button, it will heal armor before health. The project is here: https://github.com/austingaee/DamageHealth-...
0
votes
0answers
16 views

Quick-Dial Button/ActionSheet within ViewController

I'm creating a button that will dial a user quickly in to their conference calls should they have a default provider set. If they have no default provider an action sheet will appear that allows them ...
7
votes
1answer
114 views

Swiftly counting rooms in a floor plan

Inspired by recent questions about counting the rooms in a floor plan (1, 2, 3), here is my attempt to solve the problem with a Swift program. The problem (from “Counting Rooms” on CSES) is: You ...
0
votes
1answer
52 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
0answers
130 views

Candidate registration, with validation, using MVVM

I am new to MVVM. I Created Model class CandidateRegisterModel and ViewModel class CandidateRegisterViewModel ...
3
votes
1answer
59 views

Custom caching class in Swift

I'm using Swift 4.0 and I'm using UserDefaults in my project for storing Strings like login or something. I have a class: ...
4
votes
1answer
67 views

A helper class for creating icons from a PNG image and colour in Swift

I have made a helper struct in Swift that creates circular icons from a PNG image (a white icon on transparent background) and a background ...
3
votes
1answer
101 views

Adding dragging ability to a UIView using protocols

I recently published an iOS control/component called BJDraggable which basically, with a call of a method, enables us to drag a view within its superview boundary. ...
2
votes
1answer
62 views

UITableViewDataSource with different sections and SearchController

I have a UIViewController holding one UITableView with 3 sections. Also this UIViewController implements ...
4
votes
0answers
1k views

Page and center UICollectionView like App Store

I need a collection view to page through cells and center it like the App Store, where a portion of the previous and next cells look like this: The native ...
4
votes
1answer
225 views

A consumable byte array, in Swift

For decoding binary data (in my case, delivered by a Bluetooth device), I've written this struct: ...
1
vote
1answer
348 views

Numbers as Strings Multiplication Function in Swift

I was solving a problem 20, Factorial Digit Sum, on Project Euler. Factorial Digits Sum \$n!\$ means \$n \cdot (n − 1) \cdot \ldots \cdot 3 \cdot 2 \cdot 1\$ For example, \$10! = 10 \cdot ...
1
vote
1answer
73 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 ...
2
votes
1answer
216 views

iOS Memory Game - Swift 4

I'm learning iOS through this past Stanford CS193P course. I've just completed the first assignment and would love a code review as I can't actually turn in an assignment for feedback since the course ...
0
votes
0answers
294 views

Uploading files asynchronously in Swift using Alamofire

I recently began a tutorial to familiarize myself with uploading content to RestAPIs via Alamofire. I've a habit during tutorials to try and clean up the code as I go along to better drill in what the ...
0
votes
0answers
42 views

Creating a class that builds modal views to display announcements or issues

I'm looking to create a class that will display a template pop-up to the user to alert them to new features/updates and when their calendar isn't synchronised correctly. I'd like to do this in a ...
2
votes
0answers
97 views

Log in user through json and display the application

I am currently learning swift 4 and would like to ask you to correct my code. (I would like to have a pattern for learning the "beautiful code"). My code gets data from the server in JSON format and ...
4
votes
2answers
149 views

Initializing an Array of Alternating Values

My goal in this project is to make something that can—as, quickly, effectively, and efficiently as Array(repeating: , count: )—initialize an ...
6
votes
1answer
79 views

Downset calculation code

I'm looking to port a Python script I have over to Swift, partly for some performance benefits, and partly to dip my toe into a new language. My program computes what is called the downset of a ...
4
votes
1answer
113 views

iOS Swift 3 app that requests data from the Stack Exchange API

This is my first Swift app, so I want to improve everything that I can about my code and know what I can do better. The app requests 10 developers from StackExchange API and displays them in a table ...
7
votes
1answer
202 views

Prime Number Generator & Efficiency

If anyone can explain to me the advantages of using things like the Sieve of Atkin over the Sieve of Eratosthenes, and how to code it (especially the Sieve of Atkin), that would be highly appreciated. ...
2
votes
1answer
2k views

Grouping Date Objects by year and month

I have an array of date objects, which I want to group by year and month. The data structure I have chosen for my target is an array of arrays of Date objects. Two Date objects should be in the same ...