So, this might be a little bit messy for me to explain, but here it goes.
I have, what i think are, numbers stored in core data and i am trying to convert them into strings so that i can use them as labels for table cells, maybe dumb but please bear with me.
I pump the core data items into an array and am trying to get them back out, i run a FOR loop and use this code to make a number for each item.
NSNumber *num = [arr objectAtIndex:i];
When i run, i get no errors and if i log them i get everything returned as expected. However, if i run this afterwards program force quits.
NSString *myOutput = [num stringValue];
I believe it is because what ever i actually have and am pulling out is not really a number therefore it cannot be made into a string using stringValue, anyone know a way to test for what an object is? Maybe using NSLog some how?
Also side question. In a FOR loop where i create objects I need to remember to release them each time the loop is run correct?
Thanks so much!
There’s a few ways of checking what objects contain or whether they are of a certain type; either the
check – if you break on a line after it you can see the class. With your NSNumber though, it will either be a number or have nothing inside it, ie
Finally, there is this test – also perfectly viable:
Also yes – you should release objects created in your for loop for best memory management and code efficiency. Hope this helps 🙂