//
// copyproperty.m
// bocktest
//
// Created by Blaine Garst on 3/21/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
// CONFIG GC RR
#import <Foundation/Foundation.h>
#include <stdio.h>
@interface TestObject : NSObject {
long (^getInt)(void);
}
@property(copy) long (^getInt)(void);
@end
@implementation TestObject
@synthesize getInt;
@end
@interface CountingObject : NSObject
@end
int Retained = 0;
@implementation CountingObject
- (id) retain {
Retained = 1;
return [super retain];
}
@end
int main(char *argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
TestObject *to = [[TestObject alloc] init];
TestObject *co = [[CountingObject alloc] init];
long (^localBlock)(void) = ^{ return 10L + (long)[co self]; };
to.getInt = localBlock;
if (localBlock == to.getInt) {
printf(" return 1;
}
if (![NSGarbageCollector defaultCollector] && Retained == 0) {
printf(" return 1;
}
printf(" return 0;
}