5
votes

In swift I declared a variable as

let context:LAContext = LAContext()

It throws a warning

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

1

1 Answers

14
votes

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.