Question

In reference to https://stackoverflow.com/a/10319761/1680408. In my app a user can upload audio video and images to a server. If the application goes into the background, I need that task to remain until it finishes. I implemented the solution that the post suggested and it works! However, it generates funny warnings.

with the below one, I get: "Incompatible integer to pointer conversion assigning to 'UIBackgroundTaskIdentifier *'(aka 'unsigned int *') from 'UIBackgroundTaskIdentifier'(aka 'unsigned int')

- (void)beingBackgroundUpdateTask
{
self.backgroundUpload = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
    [self endBackgroundUpdateTask];
}];

//
}

with this next one I get a fix it suggestion: "Incompatible pointer to integer conversion sending 'UIBackgroundTaskIdentifier *'(aka 'unsigned int *') to parameter type 'UIBackgroundTaskIdentifier' (aka 'unsigned int'); deference with *

- (void)endBackgroundUpdateTask
{
self.backgroundUpload = UIBackgroundTaskInvalid;
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundUpload];
}

which when I use the fix it suggestion the code doesnt work. To be hoenst, I'm not too fussed because it works. However I am worried that Apple would reject my app because of this. So kinda just want to be better safe than sorry. Unless someone out there knows for a fact that this type of issue wouldn't be rejected. So weird! Any other time I get this type of warning my app crashes! I did some searching for this but suggestions didn't really help. Anyone know if there's a quick fix or just a fix in general fix for this?

Thanks!

Était-ce utile?

La solution

How did you declare variable backgroundUpload?

UIBackgroundTaskIdentifier *backgroundUpload;

This will give this warning. Remove the * from the above line.

UIBackgroundTaskIdentifier backgroundUpload;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top