Beobachten CLLocationCoordinate2D in iPhone SDK

stimmen
0

Im iPhone SDK können wir nur Objekte beobachten, und nicht Streben wie CLLocationCoordinate2D?

Beispiel: Ich habe einige sehr einfachen Code, wo ich eine Eigenschaft vom Typ beobachten möchte CLLocationCoordinate2D, ich habe dafür gesorgt , es in ABC.m. zu synthetisieren

@interface ABC
{
 CLLocationCoordinate2D currentLocation;
}
@property (nonatomic, readwrite) CLLocationCoordinate2D currentLocation;

Nun in einer anderen Klasse I tun:

[ABC addObserver:self forKeyPath:@currentLocation options:NSKeyValueObservingOptionNew context:NULL];

Aus irgendeinem Grund, berichtet die observeValueForKeyPath Methode nie das Schlüsselpfad „ currentLocation“ geändert.

Vielen Dank,

Sjs

Veröffentlicht am 28/08/2009 um 04:51
quelle vom benutzer
In anderen Sprachen...                            


1 antworten

stimmen
0

Ist das die wörtliche Anruf, dass Sie machen?

[ABC addObserver:self forKeyPath:@"currentLocation" options:NSKeyValueObservingOptionNew context:NULL];

Wenn ja, dann denke ich, das Problem ist, dass Sie die Klasse ABC und nicht eine Instanz der Klasse ABC beobachten. Unter der Annahme, dass Sie eine Instanz der Klasse ABC haben versuchen, das zu beobachten.

ABC* myObject = [ [ [ ABC alloc ] init ] autorelease ];
[ myObject addObserver: self forKeyPath: @"currentLocation" options: NSKeyValueObservingOptionNew context: NULL ];
Beantwortet am 29/08/2009 um 14:01
quelle vom benutzer

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more