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,我无法用它来调试程序。
如果我直接运行已安装的程序,代码将产生以下结果:
��
<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'
什么是委托代理?