I'm puzzled by a remark from Xcode' analyzer. I've searched Stack about it but didn't really find a similar situation. I have a CoreData/SQLite app where the user select a record in a table, gets all the atributes for the entity. then, based on conditions, will do things.
"ordersController" is the NSArrayController for the data. "Order" is the involved entity. "objectAtIndex:0" is the selected record in the table.
Here is the code:
NSArray* selectedObjects = [ordersController selectedObjects];
NSEntityDescription *entityOrder = [NSEntityDescription entityForName:@"Order" inManagedObjectContext:managedObjectContext];
entityOrder = [selectedObjects objectAtIndex:0];
if ([entityOrder valueForKey: bla_bla_bla... { do_something }
The app compiles fine, no crash, no warning and correctly handles the data as intended. However when I start the Analyze tool of Xcode, it points at this line, saying "Value stored to 'entityOrder' during its initialization is never read."
NSEntityDescription *entityOrder = [NSEntityDescription entityForName:@"Order" inManagedObjectContext:managedObjectContext];
How can it be not read when it is actually manipulated and the variable is correctly modified by the app? How should I improve my code? Thansk for your help.
Immediately after the line
you then reassign it to the contents of first object of
selectedObjects
withThe Xcode analyzer is letting you know that the first assignment is superfluous, or you are assigning the results of
[selectedObjects objectAtIndex:0]
to the wrong variable in your code.