供参考,我正在使用Xcode 11.3
我遇到了已发布的对象的问题,这导致EXC BAD ACCESS。好消息是我确切地知道对象是什么。我不知道该怎么解决。
这里是发生崩溃的代码...
- (void)didSendPTPCommand:(NSData*)command inData:(NSData*)data response:(NSData*)response error:(NSError*)error contextInfo:(void*)contextInfo
{
NSLog(@"%@ %@ %@ %@", NSStringFromSelector(_cmd), data, response, error);
PTPOperationRequest* ptpRequest = (__bridge PTPOperationRequest*)contextInfo;
PTPOperationResponse* ptpResponse = NULL;
if ( ptpRequest )
崩溃已打开:
PTPOperationRequest* ptpRequest = (__bridge PTPOperationRequest*)contextInfo;
此代码被从此代码中调用:
ptpData = NULL;
PTPOperationRequest* request = [[PTPOperationRequest alloc] init];
request.operationCode = PTPOperationCodeInitiateCapture;
request.numberOfParameters = 0;
commandBuffer = request.commandBuffer;
[camera requestSendPTPCommand:commandBuffer
outData:NULL
sendCommandDelegate:self
didSendCommandSelector:@selector(didSendPTPCommand:inData:response:error:contextInfo:)
contextInfo:(__bridge void * _Nullable)(request)];
我试图通过“请求”的诅咒。很久以前,我可以通过保留/释放来管理此操作-不再。我现在该怎么办?
我想我现在有解决方法。
__bridge_retained
因此更改了以下代码:
[camera requestSendPTPCommand:commandBuffer
outData:NULL
sendCommandDelegate:self
didSendCommandSelector:@selector(didSendPTPCommand:inData:response:error:contextInfo:)
contextInfo:(__bridge_retained void * _Nullable)(request)];
我已经测试过并且可以正常工作。