Malloc
Malloc

Reputation: 16296

Cannot declare variable inside @interface or @protocol : How to deal with

A while ago, I developed an app with GCC compiler, now I upgrade to use Apple LLVM compiler 4.2, and getting many errors of kind : Cannot declare variable inside @interface or @protocol

Here is an example:

@interface HomeController(PRIVATE)
NSMutableArray *array;
@end

I know I cannot declare ivars in Categories, but if I change them to properties, it will not make sense, since some ivars are referencing extern classes.

How you usually deal with these kind of issues? Thanx in advance.

Upvotes: 2

Views: 3733

Answers (2)

Heckscheibe
Heckscheibe

Reputation: 640

you can do this like that:

@interface HomeController (){
NSMutableArray *array;
}

then these variables are private...

Upvotes: 1

Dan F
Dan F

Reputation: 17732

If you want it to be "private" what I usually do is usually create an unnamed category and declare the ivars in there like this:

@interface MyClass()
{
    NSArray *myArray;
}
@end

I'm not sure if its the named part of your category, or that you are missing the braces thats the problem, but this works for me

Upvotes: 5

Related Questions