In an iOS app, I receive NSMetadataQuery results on the main thread, but process them in a separate background queue. One of the actions is to get a number of attributes from the NSMetadataItems returned by the query.
For example:
metadataQueryWorkerQueue.addOperationWithBlock
{
let displayName = metadataItem.valueForAttribute(NSMetadataItemDisplayNameKey)
// ...
}
Once in a while I receive crash reports similar to the one below, crasing at [NSMetadataItem valueForAttribute:].
Do I have to use NSMetadataItem on the same queue that the NSMetadataQuery instance uses as its "operationQueue" or can I hand them off to another background thread to get its attributes?
---
Crash report:
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x10
Crashed Thread: 11
Application Specific Information:
objc_msgSend() selector name: _createSubstringWithRange:
Thread 11 Crashed:
0 libobjc.A.dylib 0x0000000181931bd0 objc_msgSend + 16
1 CoreFoundation 0x00000001821bb244 _retainedComponentString + 188
2 CoreFoundation 0x00000001821bad90 CFURLCreateStringWithFileSystemPath + 392
3 CoreFoundation 0x00000001821c4c20 CFURLCopyFileSystemPath + 424
4 Foundation 0x0000000182b90554 -[NSURL(NSURL) path] + 156
5 CloudDocs 0x0000000191d21b58 -[NSURL(BRAdditions) br_unresolvedPathIsInLocalVolume] + 112
6 CloudDocs 0x0000000191d22984 -[NSURL(BRAdditions) br_pathRelativeToMobileDocuments] + 84
7 CloudDocs 0x0000000191d22eb0 -[NSURL(BRAdditions) br_containerID] + 24
8 CloudDocs 0x0000000191d231c8 -[NSURL(BRAdditions) br_cloudDocsContainer] + 24
9 CloudDocs 0x0000000191d19018 __25+[BRQueryItem initialize]_block_invoke_24 + 36
10 Foundation 0x0000000182c06ba0 -[NSMetadataItem valueForAttribute:] + 176