0
    PO(self);
    PO(_locationManager.delegate);
    PO([CLLocationHandler singleton]);
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.delegate = self;
    PO(self);
    PO(_locationManager.delegate);
    NSAssert(_locationManager.delegate==self,@"They are meant for each other");

したがって、このコードはシミュレーターとほとんどの iPhone で機能します。私のビジネス パートナーが所有している、プログラムをデバッグできない魔法の iPhone が 1 台あります。

インストールしたプログラムを直接実行すると、コードは次のようになります。

��

<Warning>: *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
<Warning>: self: <CLLocationHandler: 0x1f8df560>
<Warning>: _locationManager.delegate: (null) <Warning>: [CLLocationHandler singleton]: <CLLocationHandler: 0x1f8df560>
<Warning>: self: <CLLocationHandler: 0x1f8df560>
<Warning>: _locationManager.delegate: <RwXSxTb_DelegateProxy: 0x1e594d00>
<Warning>: *** Assertion failure in -[CLLocationHandler additionalInitialization], /business/Dropbox/badgers/BadgerNew/CLLocationHandler.m:251
<Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'They are meant for each other'

delegateProxy って一体何?

4

2 に答える 2

2

プロパティからの読み取りがまったく同じ値を返すという保証はありません。

プロパティは、getter および setter メソッドを呼び出すための構文糖衣であり、これらのメソッドは何でも実行できます。

あなたの場合、-[CLLocationHandler setDelegate:]値をプロキシにラップしているようです。代わりにオブジェクトを比較してみてくださいisEqual:。多くのプロキシはそれを正しく処理します。

于 2013-07-19T11:34:43.877 に答える