swift-protocols Questions
9
Solved
I want to create a class that can store objects conforming to a certain protocol. The objects should be stored in a typed array. According to the Swift documentation protocols can be used as types:...
Lungi asked 22/7, 2014 at 13:21
4
Solved
I would like to nest a protocol in my class to implement the delegate pattern like so :
class MyViewController : UIViewController {
protocol Delegate {
func eventHappened()
}
var delegate:My...
Desideratum asked 17/3, 2016 at 16:33
6
Solved
In a UIViewController (rolePageController) I configure another UIViewController (drawerController) and pass it 2 UIViews from the role page that will be part of the drawerController's configuration...
Ieshaieso asked 7/12, 2018 at 2:30
8
Solved
weak references don't seem to work in Swift unless a protocol is declared as @objc, which I don't want in a pure Swift app.
This code gives a compile error (weak cannot be applied to non-class typ...
Marcos asked 5/6, 2014 at 17:16
1
Solved
Having a problem with a protocol & generics that I am just not able to quite get a handle on.
In the code below, marked by ERROR HERE comment, I am getting the following error:
Member 'protoco...
Bullyrag asked 25/12, 2022 at 3:21
1
Solved
When I try to define an actor that conforms to a protocol, Xcode gives me the error Actor-isolated instance method 'foo()' cannot be used to satisfy nonisolated protocol requirement. I can make the...
Leffert asked 6/12, 2022 at 14:26
4
Solved
I'd like to write an extension for tuples of (e.g.) two value in Swift. For instance, I'd like to write this swap method:
let t = (1, "one")
let s = t.swap
such that s would be of type (String, ...
Cupboard asked 4/2, 2015 at 9:18
2
Is there a difference between these two in Swift?
protocol ABProtocol: AProtocol, BProtocol {}
typealias ABProtocol = AProtocol&BProtocol
Butterbur asked 28/10, 2022 at 8:15
2
I'm a bit confused by an error I'm seeing in the new Xcode beta around the new any syntax in Swift.
I have a view that takes an any Hashable, and I'm trying to pass that to a parameter that takes a...
Ferreira asked 8/7, 2022 at 15:58
1
Solved
I'm trying to create a Codable struct with an [any Protocol] in Swift 5.7
struct Account: Codable {
var id: String
var name: String
var wallets: [any Wallet]
}
protocol Wallet: Codable {
var i...
Headway asked 26/7, 2022 at 12:47
6
Solved
Protocol can only be used as a generic constraint because it has Self or associatedType requirements
I have a protocol RequestType and it has associatedType Model as below.
public protocol RequestType: class {
associatedtype Model
var path: String { get set }
}
public extension RequestType {...
Pardner asked 1/4, 2016 at 4:29
2
In Swift, the following code compiles without issue.
protocol P1 {
associatedtype T = Int
}
protocol P2 {
typealias T = Int
}
To me, these appear to behave almost identically. The only differ...
February asked 10/4, 2019 at 22:26
2
Solved
It seems reasonable to use UML Interfaces to visualize Swift Protocols in UML. But how should I visualize an extension that provides a default implementation for a specific protocol? Should I just ...
Heisser asked 29/5, 2016 at 12:35
19
Solved
Is it possible in Swift? If not then is there a workaround to do it?
Trial asked 4/6, 2014 at 8:41
6
Solved
I'm trying to create a UIViewController extension that I can use to initialise new instances. For each view controller in my project I have a corresponding storyboard.
i.e.
EditSomethingViewCon...
Dehnel asked 9/5, 2017 at 15:49
5
Solved
I have created on Class in Swift and that class and its protocol I am using in Obj-C enabled project but I am getting below error while compiling my project.
cannot find protocol declaration for...
Backbencher asked 29/8, 2017 at 5:38
4
Solved
I have a doubt about protocols in Swift about the use of var and the keywords { get set }.
From Apple documentation:
If a protocol requires a property to be gettable and settable, that
propert...
Phail asked 20/12, 2015 at 21:12
1
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 extensi...
Flipflop asked 18/6, 2019 at 9:16
3
Solved
I'm working on an app, and need to pass data between view and containerView. I need to send data and receive data from both Views.
Let me explain better:
I can change the Label Master (Touch the ...
Rags asked 18/12, 2015 at 3:51
3
Solved
So I'm new to iOS development and have been working on minor changes to an app at my internship that has a relatively large objective-c code base. I've been learning swift from Treehouse(Wow, love ...
Cooley asked 11/11, 2017 at 23:16
3
Solved
Why does the following code produce an error?
protocol ProtocolA {
var someProperty: ProtocolB { get }
}
protocol ProtocolB {}
class ConformsToB: ProtocolB {}
class SomeClass: ProtocolA { // Ty...
Gastrectomy asked 2/3, 2017 at 17:9
4
Solved
Swift has a notion of class interfaces, called Protocols. However I can't seem to find a full reference of all protocols available in the Swift API. Where can I find a list of all protocols?
Tabanid asked 23/6, 2014 at 19:5
3
Solved
I have 2 protocols, Filters and Parameters, both of which extend Encodable
protocol Filters: Encodable {
var page: Int { get }
}
protocol Parameters: Encodable {
var type: String { get }
var fi...
Lucienlucienne asked 15/5, 2018 at 8:54
1
I'm running a Vision Framework request for an iOS app like follows:
let textDetectionRequest = VNDetectTextRectanglesRequest(completionHandler: self.findTextBoxes)
let textDetectionHandler = VNIma...
Periwig asked 30/12, 2017 at 10:21
8
Solved
Is there a standard way to make a "pure virtual function" in Swift, ie. one that must be overridden by every subclass, and which, if it is not, causes a compile time error?
Bevatron asked 8/6, 2014 at 22:7
1 Next >
© 2022 - 2025 — McMap. All rights reserved.