https://github.com/simplisticated/hammer
Powerful tool for managing objects
https://github.com/simplisticated/hammer
architecture classes nsobject patterns swift
Last synced: about 2 months ago
JSON representation
Powerful tool for managing objects
- Host: GitHub
- URL: https://github.com/simplisticated/hammer
- Owner: simplisticated
- License: mit
- Created: 2018-06-01T10:42:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-02T07:43:47.000Z (about 5 years ago)
- Last Synced: 2025-03-23T15:17:04.716Z (2 months ago)
- Topics: architecture, classes, nsobject, patterns, swift
- Language: Swift
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
## At a Glance
`Hammer` is a powerful tool for solving common tasks with classes and objects.
## How To Get Started
- Copy content of `Source` folder to your project.
or
- Use `Hammer` cocoapod
## Requirements
* iOS 9 and later
* Xcode 9 and later
* Swift 4## Usage
### Class Name
Retrieve class name:
```swift
let classNameWithNamespace = MainViewController.hmr.fullName // "MyApplication.MainViewController"
let classNameWithoutNamespace = MainViewController.hmr.shortName // "MainViewController"
```### Object Conversions
Use object in external closure:
```swift
let label = UILabel().hmr.use { (label) in
label.text = "This is a label"
}.object
```Use object converted to another type in external closure:
```swift
let view = SomeView().hmr.use(as: UILabel.self) { (label) in
label.text = "This is a label"
}.object
```### Object Retaining
Retain any object:
```swift
object.hmr.hold()
```Release the object:
```swift
object.hmr.free()
```### Container
Any object can be easily wrapped by special container:
```swift
let number: NSNumber? = nillet container = number.hmr.wrap()
container.value // nil
container.isNil // true
```### Just for Fun
You can replace `hmr` with hammer emoji:
```swift
let classNameWithNamespace = MainViewController.🔨.fullName
let classNameWithoutNamespace = MainViewController.🔨.shortNamelet view = SomeView().🔨.use(as: UILabel.self) { (label) in
label.text = "This is a label"
}.object// etc.
```## License
`Hammer` is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.