I am new to Objective C and am reading a book called \"Visual Quickstart Guide: Objective-C\" by Steven Holzner, Peachpit Press
In Chapter 6: Object Oriented Program
You declare the static variable in the implementation file (.m file). This should work:
// TheClass.h
@interface TheClass : NSObject
+ (int)count;
@end
// TheClass.m
static int theCount = 0;
@implementation TheClass
+ (int) count { return theCount; }
@end
It's not a class variable per se; Objective-C has no notion of a class variable. However, coupled with the class method for retrieving this variable, it functions similarly to a class variable. However, it's really just a C static variable that's accessible by the class's implementation.