"Initialisation of immutable value'context' was never used, consider replacing assignment to '_' or removing it

前端 未结 1 1420
生来不讨喜
生来不讨喜 2021-01-18 21:50

In swift I declared a variable as

let context:LAContext = LAContext()

It throws a warning

\"Initialisation of immuta

相关标签:
1条回答
  • 2021-01-18 22:16

    It's all in the error message

    value...was never used

    Your variable isn't being used anywhere, so Xcode tells you that you can remove it (because having unused variables is a waste of memory). Just use your variable somewhere and the error will go away (e.g. get a value from it, print it, etc).

    Of course you mean to use it somewhere right? Otherwise you wouldn't have declared it. It's just that the Xcode (especially the new one, I noticed) checks for errors immediately, so these kinds of errors appear before you can really do anything about it.

    0 讨论(0)
提交回复
热议问题