Top "Swift-extensions" questions

Extensions add new functionality to an existing class, structure, or enumeration type.

How to add an optional string extension?

You can create a String extension like so: extension String { func someFunc() -> Bool { return true } } but what if …

swift swift-extensions
Swift - How can I override an extension method in a concrete subclass

I have an extension on UIView implementing a protocol protocol SomeProtocol { var property : Int } extension UIView : SomeProtocol { var property : Int { …

ios swift access-control swift-extensions
How to make extension for multiple classes Swift

I have an extension: extension UILabel { func animateHidden(flag: Bool) { self.hidden = flag } } I need to make the same one …

ios swift swift-extensions
Return instancetype in Swift

I'm trying to make this extension: extension UIViewController { class func initialize(storyboardName: String, storyboardId: String) -> Self { let storyboad = …

swift swift2 swift-extensions
Set (Collection) - Insert multiple elements

Set is an unordered collection of unique elements. Almost similar to array. I want to add/insert multiple elements in …

ios swift set tuples swift-extensions
How to properly use class extensions in Swift?

In Swift, I have historically used extensions to extend closed types and provide handy, logic-less functionality, like animations, math extensions …

ios swift swift-extensions system-design
Self.Type cannot be directly converted to AnyClass in extension to objective-c class in swift

I'm trying to create fabric method to create UIViewController with correct nib name (to fix iOS8 default initialiser issue). To …

ios objective-c swift type-inference swift-extensions
Generic Extension for Array in Swift

To be very frank, I am totally new to learn Extension creation and usage. I wanted to create a category (…

swift swift-extensions
Swift 'open' keyword & overridable method/properties in extension?

With introduction of open keyword in Swift 3.0 (What is the 'open' keyword in Swift?). Note: Limited to extensions on NSObject …

ios swift syntax swift-extensions