2

i initialize instance variables in .h file,

NSInteger saveValue0, saveValue1, saveValue2, saveValue3;

NSMutableArray *nodeArray;

Now in .m file, in viewWillAppear event,

saveValue0 = 0; 
saveValue1 = 2; 
saveValue2 = 3;
saveValue3 = 0;

nodeArray = [[NSMutableArray alloc] initWithObjects:saveValue0, saveValue1, saveValue2, saveValue3, nil]; 

But above variable does not inserted in the array. When i trying to see the objects in array using break point, it gives me 0 objects present in nodeArray. Why it will give me 0 objects. Any reason behind that?

2 Answers 2

2

NSInteger is not an object, and you can only store objects in arrays. Use [NSNumber numberWithInteger:0] etc.

Sign up to request clarification or add additional context in comments.

4 Comments

Unsurprisingly, this also generates a compiler warning: "warning: passing argument 1 of 'initWithObjects:' makes pointer from integer without a cast" I wonder why RRB didn't mention that?
@Mark Bessey, sorry and yes i forgetting to mention the warning message.
Thanks. There is not other way to execute my problem.
BTW @RRB, the reason you end up with no objects is that your first number was 0, which got cast to nil. That's the trigger for the end of the list of objects.
0

NSInteger is just a standard C type.U cannot add those into NSMutableArray

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.