【发布时间】:2014-09-21 14:42:16
【问题描述】:
在升级到 Xcode 6 之前,我的代码一直在编译并运行良好。
定义显示警告:自动属性合成不会合成属性“哈希”,因为它是“读写”,但会通过另一个属性“只读”合成
@property (nonatomic, strong) NSString *hash; // (get/compute) hash code of the place (master hash of images)
每当我访问 _hash 时,实现都会显示错误:使用未声明的标识符“_hash”
-(NSString *)hash {
if (_hash) return _hash;
// If place id, take it as the hash code
NSString *poiID = self.info[@"id"];
if (poiID) {
_hash = [NSString stringWithFormat:@"id-%lu",(unsigned long)[self.address hash]];
}
else if (CLLocationCoordinate2DIsValid(self.location.coordinate)) {
NSString *seed = [NSString stringWithFormat:@"%f,%f", self.location.coordinate.latitude, self.location.coordinate.longitude];
_hash = [NSString stringWithFormat:@"location-%lu",(unsigned long)[seed hash]];
}
else if (self.address) {
NSString *seed = self.address;
_hash = [NSString stringWithFormat:@"address-%lu",(unsigned long)[seed hash]];
}
else {
_hash = @"POI-unknownIDLocationOrAddress";
}
return _hash;
}
【问题讨论】:
标签: ios xcode properties