All Questions
Tagged with swift design-patterns
15 questions
2
votes
0
answers
275
views
Swift Struct-based Factory Pattern
Edit: I added another configuration vector to CardView, a size attribute, which may be .small or ...
1
vote
2
answers
264
views
Trying (and failing) to implement the best conventions on OOP Swift
I'm making a MacOS app that will do some analysis on the user's calendar data. For now it only supports Apple's native calendar (EventKit), but I will later add ...
1
vote
3
answers
3k
views
Create UIView programmatically in Swift
I am generating View and setting constraints programmatically in UIViewController
...
2
votes
3
answers
211
views
I want to take away WebService call from UIViewController
I am using Moya to make network calls in Swift.
In my ViewController I am calling the WebService and creating a model from response.
...
3
votes
2
answers
473
views
Implement The Singleton Pattern for Persistency managers Swift [closed]
I am creating an iOS app and I want to implement Singleton Pattern.
I have created "Singleton" LibraryAPI to act as an entry point UserManager object to get data from web API. after that I used a ...
1
vote
0
answers
3k
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 (...
0
votes
1
answer
482
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. ...
3
votes
0
answers
144
views
Load data from WebAPI to the ViewController
My current code working perfectly, it is for data load from web api to the UIViewController (UITableView).
But I am confused ...
0
votes
2
answers
422
views
Swift inheritance versus composition
Say I'm using Parse Server and utilising the PFObject class from the iOS SDK. Say I want to have a Chat class.
To use inheritance code (design 1):
...
0
votes
1
answer
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 ...
3
votes
2
answers
586
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 mechanic ...
2
votes
1
answer
502
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 others. ...
4
votes
1
answer
422
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 ...
10
votes
1
answer
248
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:
...
8
votes
2
answers
11k
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 ...