NO it does not matter.
Thanks Ol Sen - everything you say makes me think the answer is NO it does not matter but I am still not 100% convinced, so let me do a quick test with the code below. If it does not matter then this should run and if it does this should raise an exception somewhere. (What this does is to repeatedly call from both the main and a background thread).
// Schedule on queue
for ( int i = 0; i < 100; i ++ )
{
[self.ctl.queue addOperation:[NSBlockOperation blockOperationWithBlock: ^ {
[self.doc performAsynchronousFileAccessUsingBlock: ^ {
NSLog(@"Queue %d main %@",i,NSThread.isMainThread ? @"YES" : @"NO" );
}];
}]];
}
// Schedule on main
for ( int i = 0; i < 10; i ++ )
{
[self.doc performAsynchronousFileAccessUsingBlock: ^ {
NSLog(@"Main %d main %@",i,NSThread.isMainThread ? @"YES" : @"NO" );
}];
}
The result - it runs without any issue so now I have convinced myself and the answer is NO it does not matter. Clearly you can call this concurrently from any thread.
This is called on the main thread and self.doc
is some arbitrary open UIDocument
and self.ctl.queue
is a background queue.
I know the docs say to typically use the main thread for those operations (open, save, close) but I once got into trouble for not abiding by that, so I have been careful to message UIDocument
on the main thread only, but for this one clearly that is being too careful.