Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Commit

Permalink
Not currently working
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Crooke committed Jan 4, 2015
1 parent bd96e50 commit 689b8af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions ObjcAssociatedObjectHelpers/ObjcAssociatedObjectHelpers.h
Expand Up @@ -126,8 +126,7 @@ static void* getterName##Key = _OBJC_ASC_QUOTE(getterName); \
#define SYNTHESIZE_ASC_OBJ_WEAK_BLOCK(getterName, setterName, getterBlock, setterBlock) \
static void* getterName##Key = _OBJC_ASC_QUOTE(getterName); \
- (void)setterName:(id)value { \
value = setterBlock(value); \
id wrapped = [__ObjCAscWeakContainer wrapObject:value]; \
id wrapped = [__ObjCAscWeakContainer wrapObject:setterBlock(value)]; \
@synchronized(self) { \
_OBJC_ASC_WRAP_KVO_SETTER(getterName, objc_setAssociatedObject(self, getterName##Key, wrapped, OBJC_ASSOCIATION_RETAIN)); \
} \
Expand Down
2 changes: 1 addition & 1 deletion ObjcAssociatedObjectHelpers/ObjcAssociatedObjectHelpers.m
Expand Up @@ -28,7 +28,7 @@
@implementation __ObjCAscWeakContainer
+ (instancetype)wrapObject:(id)object {
__ObjCAscWeakContainer *wrapper = [[self alloc] init];
wrapper._object = object;
// wrapper._object = object;
return wrapper;
}
@end
10 changes: 6 additions & 4 deletions UnitTests/Specs.m
Expand Up @@ -267,16 +267,18 @@

describe(@"weak container", ^{

NSMutableArray *array = [NSMutableArray arrayWithObject:@"foo"];

it(@"should get and set a value as normal", ^{
NSMutableArray *array = [NSMutableArray arrayWithObject:@"foo"];
testObject.weakObject = array.firstObject;
expect(testObject.weakObject && testObject.weakObject == array.firstObject).to.beTruthy();
expect(testObject.weakObject).notTo.beNil();
expect(testObject.weakObject == array.firstObject).to.beTruthy();
});

it(@"should nil the weak property", ^{
NSMutableArray *array = [NSMutableArray arrayWithObject:@"foo"];
testObject.weakObject = array.firstObject;
expect(testObject.weakObject && testObject.weakObject == array.firstObject).to.beTruthy();
expect(testObject.weakObject).notTo.beNil();
expect(testObject.weakObject == array.firstObject).to.beTruthy();
[array removeAllObjects];
expect(testObject.weakObject).to.beNil();
});
Expand Down

0 comments on commit 689b8af

Please sign in to comment.