views:

153

answers:

1

I am not able to declare a static integer in h class in iphone.

 static int i;

this gives an error "expected specifier-qualifier list before static".

please help me out.How to resolve this.How can i declare a static variable globally in iphone.Thanks.

+1  A: 

There is no such thing as a global static variable. A static variable has file scope — and for .h files, that means every file it's included in gets a different variable called i. To declare a global variable, put the declaration extern int i in your header and just int i in the global scope in one implementation file (it doesn't technically matter which one).

Chuck