Skip to content

Commit

Permalink
Merge branch 'release/1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewind committed Jan 17, 2014
2 parents 0635145 + ac94307 commit 5574a7c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Objection-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.1</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>ATOM</string>
<key>CFBundleVersion</key>
<string>1.2.1</string>
<string>1.3</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Objection.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Objection'
s.version = '1.2.1'
s.version = '1.3'
s.summary = 'A lightweight dependency injection framework for Objective-C.'
s.author = { 'Justin DeWind' => '[email protected]' }
s.source = { :git => 'https://github.com/atomicobject/objection.git', :tag => "#{s.version}" }
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ If you're using [Kiwi](https://github.com/allending/Kiwi) for testing, checkout
### Static Framework and Linkable Framework
It can be downloaded [here](http://objection-framework.org/files/Objection-1.2.1.tar.gz)
It can be downloaded [here](http://objection-framework.org/files/Objection-1.3.tar.gz)
### Building Static Framework
git clone git://github.com/atomicobject/objection.git
git checkout 1.2.1
git checkout 1.3
#### iOS
Expand All @@ -350,7 +350,7 @@ It can be downloaded [here](http://objection-framework.org/files/Objection-1.2.1
Edit your Pofile
edit Podfile
pod 'Objection', '1.2.1'
pod 'Objection', '1.3'
Now you can install Objection
Expand Down Expand Up @@ -389,6 +389,6 @@ One only has to [search GitHub](https://github.com/search?l=Objective-C&p=1&q=de
* [Bubble Island](http://www.wooga.com/games/bubble-island/)
* [Monster World](http://www.wooga.com/games/monster-world/)
* [Pocket Village](http://www.wooga.com/games/pocket-village/)
* [SideReel](https://itunes.apple.com/us/app/sidereel/id41.2.170961?mt=8)
* [SideReel](https://itunes.apple.com/us/app/id417270961?mt=8)
* [Google Wallet](http://www.google.com/wallet/)

1 change: 0 additions & 1 deletion Source/JSObjectionInjectorEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#import "NSObject+Objection.h"

@interface JSObjectionInjectorEntry()
- (void)notifyObjectThatItIsReady: (id)object;
- (id)buildObject:(NSArray *)arguments;
- (id)argumentsForObject:(NSArray *)givenArguments;
- (SEL)initializerForObject;
Expand Down
14 changes: 11 additions & 3 deletions Source/JSObjectionUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,25 @@ static objc_property_t GetProperty(Class klass, NSString *propertyName) {


static id BuildObjectWithInitializer(Class klass, SEL initializer, NSArray *arguments) {
id instance = [klass alloc];
NSMethodSignature *signature = [klass instanceMethodSignatureForSelector:initializer];
NSMethodSignature *signature = [klass methodSignatureForSelector:initializer];
id instance = nil;
BOOL isStatic = signature != nil;

if (!signature) {
instance = [klass alloc];
signature = [klass instanceMethodSignatureForSelector:initializer];
}

if (signature) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:instance];
[invocation setTarget:isStatic ? klass : instance];
[invocation setSelector:initializer];
for (int i = 0; i < arguments.count; i++) {
__unsafe_unretained id argument = [arguments objectAtIndex:i];
[invocation setArgument:&argument atIndex:i + 2];
}
[invocation invoke];
[invocation getReturnValue:&instance];
return instance;
} else {
@throw [NSException exceptionWithName:JSObjectionException reason:[NSString stringWithFormat:@"Could not find initializer '%@' on %@", NSStringFromSelector(initializer), NSStringFromClass(klass)] userInfo:nil];
Expand Down
5 changes: 5 additions & 0 deletions Specs/InitializerFixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@
@interface BadInitializer : NSObject
@end

@interface Truck : NSObject
@property(nonatomic, strong) NSString *name;
+ (id)truck: (NSString *)name;
@end

12 changes: 12 additions & 0 deletions Specs/InitializerFixtures.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#import "InitializerFixtures.h"

@implementation Truck
objection_register(Truck)
objection_initializer(truck:, @"Chevy")

+ (id)truck: (NSString *)name {
NSLog(@"TRUCK!");
Truck *truck = [[self alloc] init];
truck.name = name;
return truck;
}
@end

@implementation BadInitializer
objection_register(BadInitializer)
objection_initializer(initWithNonExistentInitializer)
Expand Down
7 changes: 7 additions & 0 deletions Specs/InitializerSpecs.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@
}) should] raiseWithReason:@"Could not find initializer 'initWithNonExistentInitializer' on BadInitializer"];
});

it(@"supports initializing an object with a class method", ^{
Truck *truck = [injector getObjectWithArgs:[Truck class], @"Ford", nil];

[[truck shouldNot] beNil];
[[truck.name should] equal:@"Ford"];
});

SPEC_END

0 comments on commit 5574a7c

Please sign in to comment.