I am not very good with protocols, and I'm quite stuck right now. I am trying to make a protocol for an enum, which has a name property (or function if it needs to be).
This will allow me to get the name of an enum value, similar to conforming to…
With API I'm working with, I have a case where 1 API Endpoint can return completely different responses, based on if the call was successful or not.
In case of success, API Endpoint returns an Array of requested objects, in the root, something like…
WorkAround:
I am creating a utility class let's say BLEScanManager, which is responsible to scan nearby BLE devices. The only job of the utility class is to scan BLE devices and make a list of it.
The other classes can create an object of this…
I'm trying to add some UICollectionViewDelegate methods for my objc view controller MyViewController.m; And that view controller already conforms to and has implemented some delegate methods;
However I don't want to add…
I would like to know what is the best way to deal with this situation. I have two different view controllers, both will use the same didUpdateLocations method from CLlocationManagerDelegate. I'm using an extensions for both of them and conform them…
I made a state engine for Swift but there is something that I would like to improve in a significant way.
It is an open-source project, you can check it out here: https://github.com/mrtksn/SwiftyState
The thing that I would like to improve is the…
I encountered a weird behavior. The best way I can put it is … Not overridden protocol methods in a class extension are not called while the superclass already conforms to the protocol (via extension). However this happens only while it's build with…
I have a protocol and a class which I want to extend. The protocol requires field of some type and the class has a field with the same name and the type as Implicitly Unwrapped Optional of this type.
Can this class be extended by this protocol? If…
I have placed a UIView extension in a utilities class written in swift.
However, when I try to call a method from the extension,
The compiler tells me the
The member does not exist
Here is my extension:
extension UIView {
func addShadow() {
…
I'm relatively new to coding in general and to swift, but i'm working through an SQLite tutorial (https://www.raywenderlich.com/385-sqlite-with-swift-tutorial-getting-started). I don't understand the rationale for using an extension here. I've…
I need to create a custom keyboard that looks/feels pretty much the same like the system keyboards but is for a language that iOS doesn't have:
whenever I have to type using the system keyboard, I'm subject to the autocorrect, which not only gives…
After failing to get a live image filter on a Metal view to perform better, I was curious if my UI had some kind of impact. I have an extension on UIButton that adds a blur and shadow to them. If I comment out the stuff inside the functions, and run…
To provide some context:
P stands for property. The purpose of the code is that values of different types should be handled by individual methods (e.g. serializeInt, serializeDouble etc.), something like method overloading but the type of the…
I built an extension to the UIButton class to do fadeOut. When I use this I get memory leak warning in the profiler. I am using Swift 4 and Xcode 9.3.
Thanks in advance for any help.
extension UIButton {
func fadeOut() {
let fadeOut =…
Why can we give an instance to variable in protocol extensions while we can't give an instance to variable in the protocol itself?
In the protocol, I can't give a variable new instance but when I make an extension from this protocol I can make a new…