TypeHelper 0.1.2

TypeHelper 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2015
SPMSupports SPM

Maintained by Vadym Markov.



A simple function for getting the name of the non optional type in Swift (from optional or implicitly unwrapped optional types).

Usage

  let some: SomeClass = SomeClass()
  let someOptional: SomeClass? = SomeClass()
  let someImplicitlyUnwrappedOptional: SomeClass! = SomeClass()

  println(nonOptionalTypeName(some.dynamicType)) // <namespace>.SomeClass
  println(nonOptionalTypeName(someOptional.dynamicType)) // <namespace>.SomeClass
  println(nonOptionalTypeName(someImplicitlyUnwrappedOptional.dynamicType)) // <namespace>.SomeClass

  println(nonOptionalTypeName(Printable)) // Swift.Printable
  println(nonOptionalTypeName(Printable?)) // Swift.Printable

  println(nonOptionalTypeName(UIView)) // UIView
  println(nonOptionalTypeName(UIView?)) // UIView

Installation

TypeHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'TypeHelper'

Author

Vadym Markov, [email protected]

License

TypeHelper is available under the MIT license. See the LICENSE file for more info.