在iphone SDK中观察CLLocationCoordinate2D

在iPhone SDK中,我们只能观察对象,而不是像
CLLocationCoordinate2D
这样的支柱吗? 例: 我有一些非常简单的代码,我想观察类型为ѭ0的属性,我确保在ABC.m中合成它。
@interface ABC
{
 CLLocationCoordinate2D currentLocation;
}
@property (nonatomic, readwrite) CLLocationCoordinate2D currentLocation;
现在在另一个班级我做:
[ABC addObserver:self forKeyPath:@"currentLocation" options:NSKeyValueObservingOptionNew context:NULL];
出于某种原因,observeValueForKeyPath方法从不报告密钥路径“
currentLocation
”已更改。 谢谢, SJS     
已邀请:
这是你做的字面调用吗?
[ABC addObserver:self forKeyPath:@"currentLocation" options:NSKeyValueObservingOptionNew context:NULL];
如果是这样,那么我认为问题在于您正在观察ABC类,而不是ABC类的实例。假设你有一个ABC类的实例尝试观察。
ABC* myObject = [ [ [ ABC alloc ] init ] autorelease ];
[ myObject addObserver: self forKeyPath: @"currentLocation" options: NSKeyValueObservingOptionNew context: NULL ];
    

要回复问题请先登录注册