29,031
社区成员
发帖
与我相关
我的任务
分享
#import <Foundation/Foundation.h>
#import "Car.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Car *c = [[Car alloc] init];
Car *d = [c test];
[d test];
}
return 0;
}
#import <Foundation/Foundation.h>
@interface Car : NSObject
@property (nonatomic,copy) NSString *name;
@property (nonatomic,assign) int year;
- (Car *)test;
@end
#import "Car.h"
@implementation Car
- (NSString *)description
{
return [NSString stringWithFormat:@"name:%@,year:%d",self.name,self.year];
}
- (Car *)test
{
Car *c = [[Car alloc] init];
return c;
}
- (void)dealloc
{
NSLog(@"Deallocated");
}
@end
- (Car *)test {
Car *c = [[Car alloc] init];
c = nil;
Car *c1 = [[Car alloc] init];
return nil;
}