Мой код был компиляции и запуска замечательно, пока я не обновлен до Xcode 6.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;
}
Хорошо. Теперь мы должны явно объявить автосинхронизацию с помощью @synthesize hash = _hash; –
Взгляните на раздел [Когда поставить переменную экземпляра] (http://useyourloaf.com/blog/2012/08/01/property-synthesis-with-xcode-4-dot-4.html) в этом статья с 2012 года о Xcode 4.4 –