Objective-C global array of ints not working as expected
Posted
by Fran
on Stack Overflow
See other posts from Stack Overflow
or by Fran
Published on 2010-05-12T01:07:38Z
Indexed on
2010/05/12
1:14 UTC
Read the original article
Hit count: 264
In my MyConstants.h file... I have:
int abc[3];
In my matching MyConstants.m file... I have:
extern int abc[3] = {11, 22, 33};
In each of my other *.m files... I have
#import "MyConstants.h"
Inside 1 of my viewDidLoad{} methods, I have:
extern int abc[];
NSLog(@"abc = (%d) (%d)", abc[1], sizeof(abc)/sizeof(int));
Why does it display "abc = (0) (3)" instead of "abc = (22) (3)"?
How do I make this work as expected?
© Stack Overflow or respective owner