在iphone SDK中观察CLLocationCooperative2D
在iPhone SDK中,我们是否只能观察对象,而不是像CLLocationCooperative2D
那样的struts?
例子: 我有一些非常简单的代码,我想在其中观察 CLLocationCooperative2D 类型的属性,我已确保在 ABC.m 中综合它。
@interface ABC
{
CLLocationCoordinate2D currentLocation;
}
@property (nonatomic, readwrite) CLLocationCoordinate2D currentLocation;
现在,在另一个类中,我这样做:
[ABC addObserver:self forKeyPath:@"currentLocation" options:NSKeyValueObservingOptionNew context:NULL];
出于某种原因,observeValueForKeyPath 方法永远不会报告键路径“currentLocation
”已更改。
谢谢,
Sjs
In iPhone SDK, can we only observe Objects, and not struts like CLLocationCoordinate2D
?
Example:
I've got some very simple code where I'd like to observe a property of type CLLocationCoordinate2D
, I've made sure to synthesize it in ABC.m.
@interface ABC
{
CLLocationCoordinate2D currentLocation;
}
@property (nonatomic, readwrite) CLLocationCoordinate2D currentLocation;
Now in another class I do:
[ABC addObserver:self forKeyPath:@"currentLocation" options:NSKeyValueObservingOptionNew context:NULL];
For some reason, the observeValueForKeyPath method never reports that keypath "currentLocation
" changed.
Thanks,
Sjs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是你所说的字面意思吗?
如果是这样,那么我认为问题在于您正在观察 ABC 类,而不是 ABC 类的实例。假设您有 ABC 类的一个实例,请尝试观察它。
Is this the literal call that you make?
If so then I think the issue is that you are observing the class ABC and not an instance of the class ABC. Assuming that you have an instance of class ABC try observing that.