本帖最后由 sen 于 2014-6-17 11:38 编辑
Person.h 文件
- #import <Foundation/Foundation.h>
- @interface Person : NSObject
- @property (nonatomic,assign) int age;
- + (id)person;
- + (id)personWithAge:(int)age;
- @end
复制代码 Person.m文件- #import "Person.h"
- @implementation Person
- + (id)person
- {
- return [[[self alloc] init] autorelease];
- }
- + (id)personWithAge:(int)age
- {
- Person *p = [self person];
- p.age = age;
- return p;
- }
- - (void)dealloc
- {
- NSLog(@"%d岁的人被销毁",_age);
-
- [super dealloc];
- }
- @end
复制代码 在Person.m文件的
p.age = age; 那行报了:Property 'age' not found on object of type "Person"这个错误
NSLog(@"%d岁的人被销毁",_age); 那行报了: use og undeclares identifier '_age'
请问哪里出错了,求解答
|