Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift4.2 Type 'UIBackgroundTaskIdentifier' (aka 'Int') has no member 'invalid'

I'm getting a weird issue where code which works in one XCode project fails to compile in another. Both run Swift4.2.

Why do I get "UIBackgroundTaskIdentifier has no member 'invalid' error?

import UIKit import Foundation

//Type 'UIBackgroundTaskIdentifier' (aka 'Int') has no member 'invalid'
var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid

I can jump into the UIBackgroundTaskIdentifier definition and see this: enter image description here

like image 475
Alex Stone Avatar asked Dec 18 '22 19:12

Alex Stone


1 Answers

I had the same problem. Solved using UIBackgroundTaskInvalid instead of .invalid

var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid

Not sure why it acts so strange. In the example from raywenderlich.com code compiles without errors.

like image 126
BadCodeDeveloper Avatar answered Dec 29 '22 07:12

BadCodeDeveloper