-1

I receive the error "Unused variable 'placesList'" when I write the following:

PlacesList *placesList = [[PlacesList alloc] initWithNibName:@"PlacesList" bundle:nil];

What am I doing wrong? How can I fix it?

I am new and inexperienced with coding so take it easy on me.

Popeye
  • 11,839
  • 9
  • 58
  • 91
Luke Curran
  • 77
  • 10

2 Answers2

2

It is simply a warning that the variable placesList is not doing anything or being used, so it is just wasting memory. It is also saying that in order to make your code more optimized, you would be better off having [[PlacesList alloc] initWithNibName:@"PlacesList" bundle:nil];, rather than assigning a pointer to keep a reference to it. You can ignore this warning if you plan to do more with the variable.

Adam Evans
  • 2,072
  • 1
  • 20
  • 29
1

After this line do you do anything with placeList? If not then the variable is unused, simple. just because you have this line doesn't mean it is getting used. The compiler is telling you that you have create a variable that isn't getting used anywhere so in turn isn't needed as it is just using unnecessary memory. Once you start using this variable then it will go away

Popeye
  • 11,839
  • 9
  • 58
  • 91