protocol-extension Questions

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

4

I'm building simple theme engine and would like have an extension which adds UISwipeGestureRecognizer to UIViewController Here is my code: protocol Themeable { func themeDidUpdate(currentTheme: ...
Demography asked 14/4, 2016 at 16:52

6

Solved

When implementing a static protocol function returning Self in a protocol extension, an error appears at the implementation of the function in the extension (minimal simplified scenario shown witho...
Partizan asked 15/12, 2015 at 13:1

4

Solved

I'd like to do something like this, but can't get the syntax right or find anywhere on the web that gives the right way to write it: protocol JSONDecodeable { static func withJSON(json: NSDiction...
Blalock asked 19/10, 2015 at 16:22

3

Solved

I found an interesting behaviour which seems like a bug... Based on the behaviour described the following articles: https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatc...
Brownell asked 18/1, 2016 at 4:24

4

I have a set of view controllers which will have a Menu bar button. I created a protocol for those viewControllers to adopt. Also, I've extended the protocol to add default functionalities. My pr...
Hypocrite asked 25/11, 2015 at 14:23

2

I have a protocol with an associatedType. I want to give a default typealias for that type in the protocol extension. This is to be done only for classes that inherit from a particular class. pro...
Reuven asked 28/5, 2016 at 7:22

2

I have an Objective-C protocol which is used by mostly objective-C objects and one or two Swift objects. I would like to extend the protocol in Swift and add 2 functions. One to register for a noti...
Peart asked 16/8, 2016 at 17:19

5

Let's consider the following code: protocol A { func doA() } extension A { func registerForNotification() { NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardD...
Quoin asked 8/10, 2015 at 17:40

5

Solved

So I'm trying to extend Swift's integer types with a few convenient functions that I use a lot, however I'm not clear on which protocols I should be extending. As an example, let's say I want to i...
Gilboa asked 11/8, 2015 at 13:55

3

Is it possible to call methods defined in a protocol extension in Swift from Objective-C? For example: protocol Product { var price:Int { get } var priceString:String { get } } extension Produ...
Carolynecarolynn asked 24/9, 2015 at 13:36

1

Solved

I have been playing around with protocol extensions and I have a problem. Maybe what I want to achieve can’t be done. I have this playground: //: Playground - noun: a place where people can play ...
Systematist asked 15/9, 2015 at 9:36

2

Is it possible to add protocol compliance to a different protocol by way of an extension? For instance we would like A to comply with B: protocol A { var a : UIView {get} } protocol B { var b ...
Keramics asked 19/5, 2016 at 14:28

2

Solved

I have the following code: func registerNotification(name:String, selector:Selector) { NSNotificationCenter.defaultCenter().addObserver(self, selector: selector, name: name, object: nil) } func ...
Ducharme asked 23/3, 2016 at 8:52

3

I'm trying to implement the CLLocationManagerDelegate protocol requirements via a protocol extension, but the location manager doesn't see it in the protocol extension and fails. However, it works ...
Regent asked 20/2, 2016 at 15:8

2

Consider the following: protocol Foo { typealias A func hello() -> A } protocol FooBar: Foo { func hi() -> A } extension FooBar { func hello() -> A { return hi() } } class FooBarCl...
Wisner asked 28/11, 2015 at 5:35

1

Solved

Consider the following: protocol ViewControllable: class { typealias VM: ViewModellable var vm: VM! { get } func bind() } extension ViewControllable { var vm: VM! { didSet { bind() } } }...
Ultrasonic asked 23/11, 2015 at 3:48

3

Solved

I have a fairly big application which has a lot of collection views. Most of the collection view have same implementations for Data Source and the Flow Layout Delegate (same sizes, margins etc). I ...

2

Solved

protocol Car { static func foo() } struct Truck : Car { } extension Car { static func foo() { print("bar") } } Car.foo() // Does not work // Error: Car does not have a member named foo T...
Ola asked 14/8, 2015 at 8:48
1

© 2022 - 2024 — McMap. All rights reserved.