When you call getData on a PFFile, if isDataAvailable returns true then this should not cause the a blocking operation to be executed, right?
I'm getting the following warning: Warning: A long-running Parse operation is being executed on the main thread. when doing something like
if (isDataAvailable)
[... getData];
but I still get the warning.
Warning: A long-running Parse operation is being executed on the main thread.
is sent because parse wants to warn you that you shouldn't execute heavy operations like getting data on the main thread. This could cause UI complications, and it risks getting rejected based on poor UX.
You should be running
[yourPFFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
// data available here, put any operations dependent on the data existing here
}
else {
// notify user that there was an error getting file, or handle error
}
}];
With this, parse checks first to see if the data is available before downloading new data. That way you can avoid checking isDataAvailable in your code and it won't block the main thread if there's a shotty connection or a large file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With