0

I am having a strange issue with initializing two int variables.

Here is my code:

int allHours;
int allMinutes;

NSLog(@"%d,%d",allHours,allMinutes);

And my output is: 1,-1608887932

What are these strange values? Is not 0 the default value for ints?

Thanks!

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
  • no, C, which Objective-C is a super set of, doesn't initialize non `static` variables for you. – Jack Jun 23 '16 at 23:22
  • @Jack True in this case, but not in general. Non-static variables that are an object reference other than unsafe unretained, are initialized. (Estimation: >80%) – Amin Negm-Awad Jun 24 '16 at 04:40

0 Answers0