I'm trying to write an extension that extends enums based on strings. The way I know to extend all enumerations is to extend RawRepresentable, but I want it restricted to strings-only.
extension RawRepresentable where RawRepresentable.RawValue ==…
I would like to make CountableClosedRange conform to the ExpressibleByIntegerLiteral protocol so that I can create "single integer ranges" (see my other question). The goal is to be able to assign integer literals to variables of type…
I'm new to iOS development and have read articles about the extension. But I couldn't find any examples about extending and inheriting from an extension.
Take SpreadsheetView as an example. I want to override the extension SpreadsheetView.
I found…
I am using BMPlayer library and want to implement custom control, for which I have the following class which confirm to following protocol
@objc public protocol BMPlayerControlViewDelegate: class {
func controlView(controlView:…
Hello my goal here is to extend (in swift 3) a protocol I have in a framework to conform to another Protocol
protocol SomeProtocol {}
protocol SomeOtherProtocol {}
extension SomeOtherProtocol: SomeProtocol {}
The problem here is that I get an…
I'm writing a protocol that has a readOnly label. I want to extend it and give it a default implementation where the conforming type is a UITextView.
Code:
protocol CountingView {
var keyboardLabel : UILabel {get}
}
extension CountingView…
I have a library that is written in Objective-C and using .m and .h files.
Is it possible for me to write an extension method for that class and get access to a private property that is only defined in the .m file and not defined in the .h file?
I…
I'm a beginner in iOS/Swift and trying to create a simple application without Storyboard.
I created a UIButton extension and I would like to add a simple button to my view (constraints will be set later).
Unfortunately the button is not visible.
I…
I want use a method defined in an extension to UIImageView in my ViewController. When the extension is in the same file as the view controller it works, however - I want to move it to it's own separate/public file, UIImageView+Download.swift. When I…
I am using two pods: DropDown and SwiftyUtils.
DropDown adds in a UIView subclass called DropDown. The DropDown class defines its own width property. Instead of setting the frame, the client code has to set the width of the drop down menu using this…
I'm trying to extend a struct that is already inside a struct. When I write the following code, I get
declaration is only valid at file scope.
struct A {
struct AA {
}
}
extension A {
extension AA {
}
}
Is it invalid to write…
I have a static method created on extension of Date. I am trying to call this method in Objective-C file. I am getting error as "No Known class for selector method name".
More detail:
In SWIFT 3.0
extension Date {
static func …
I'm trying to create a protocol that has a static method that returns a generic type. In most cases what I have seems to work reasonably well. The challenge comes in when I want to use an extension to return this generic value. Here's what I have.…
extension Array where Element: _ArrayType, Element.Generator.Element: Any {
func transpose() -> [Element] {
if self.isEmpty { return [Element]() }
let count = self[0].count
var out = [Element](repeating: Element(),…