我正在从 App Store 收听/观看关于 Paul Hegarty 的教程。在他的课程中,他指出您应该始终在实现文件上综合您的属性,如下所示:
@sysnthesize example = _example;
我也在做一个不综合属性的苹果文档教程。它也有像这样的初始化方法:
- (id)initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date
{
self = [super init];
if (self)
{
_name = name;
_location = location;
_date = date;
return self;
}
return nil;
}
@end
如果像这样将它们加在一起,它们是否会相互作用、取消或以其他方式相互混淆:
@implementation BirdSighting
@synthesize name = _name;
@synthesize location = _location;
@synthesize date = _date;
- (id)initWithName:(NSString *)name location:(NSString *)location date:(NSDate *)date
{
self = [super init];
if (self)
{
_name = name;
_location = location;
_date = date;
return self;
}
return nil;
}
@end
谢谢您的帮助。