Hammer
is a powerful tool for solving common tasks with classes and objects.
- Copy content of
Source
folder to your project.
or
- Use
Hammer
cocoapod
- iOS 9 and later
- Xcode 9 and later
- Swift 4
Retrieve class name:
let classNameWithNamespace = MainViewController.hmr.fullName // "MyApplication.MainViewController"
let classNameWithoutNamespace = MainViewController.hmr.shortName // "MainViewController"
Use object in external closure:
let label = UILabel().hmr.use { (label) in
label.text = "This is a label"
}.object
Use object converted to another type in external closure:
let view = SomeView().hmr.use(as: UILabel.self) { (label) in
label.text = "This is a label"
}.object
Retain any object:
object.hmr.hold()
Release the object:
object.hmr.free()
Any object can be easily wrapped by special container:
let number: NSNumber? = nil
let container = number.hmr.wrap()
container.value // nil
container.isNil // true
You can replace hmr
with hammer emoji:
let classNameWithNamespace = MainViewController.🔨.fullName
let classNameWithoutNamespace = MainViewController.🔨.shortName
let view = SomeView().🔨.use(as: UILabel.self) { (label) in
label.text = "This is a label"
}.object
// etc.
Hammer
is available under the MIT license. See the LICENSE file for more info.