Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenharman/becomes
Allow an object to pose as an object of a different class.
https://github.com/stevenharman/becomes
Last synced: 2 days ago
JSON representation
Allow an object to pose as an object of a different class.
- Host: GitHub
- URL: https://github.com/stevenharman/becomes
- Owner: stevenharman
- License: other
- Created: 2013-06-09T02:00:01.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-17T23:24:18.000Z (over 11 years ago)
- Last Synced: 2025-01-03T15:45:47.243Z (11 days ago)
- Language: Objective-C
- Size: 130 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Becomes
A hack, in coordination with [@coreyhaines](https://github.com/coreyhaines),
and with little adult supervision, to make one Objective-C object behave like
another. Think, extending an object with a module in Ruby```ruby
jedi = AnakinSkywalker.new
jedi.side_of_the_force #=> "Light Side"
jedi.force_choke #=> NoMethodError
jedi.extend(DarkSide)
jedi.side_of_the_force #=> "Dark Side"
jedi.force_choke #=> :metal:, you're choking!
```Except in Objective-C it looks more like
```objective-c
id jedi = [[AnakinSkywalker alloc] init];
[jedi sideOfTheForce]; // @"Light Side"
[jedi forceChoke]; // NSInvalidArgumentException
[jedi becomes:[DarkSide class]];
[jedi sideOfTheForce]; // @"Dark Side"
[jedi forceChoke]; // :metal:, you're choking!
```### License
See the [LICENSE file](LICENSE.md)