0

I have started new iOS project and have added only one property in ViewControler header file. but it gives me error:

expected specifier-qualifier-list before 'property'

here is the code:

#import <UIKit/UIKit.h>

@interface QuoteGenViewController : UIViewController {

    @property (retain) NSArray *myQuotes;
}

@end
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
LILkillaBEE
  • 168
  • 1
  • 5
  • 19

2 Answers2

3

Here the general structure of a class interface

@interface Class : Superclass
{
    // Instance variable declarations.
    // Theirs definition could be omitted since you can declare them
    // in the implementation block or synthesize them using declared properties.
}
// Method and property declarations.
@end

Since a property provides a simple way to declare and implement an object’s accessor methods (getter/setter), you need to put them in the Method and property declarations section.

I really suggest to read ocDefiningClasses doc for this.

Hope that helps.

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
2

Your code should look like this:

#import <UIKit/UIKit.h>

@interface QuoteGenViewController : UIViewController {

}

@property (retain) NSArray *myQuotes;

@end
Stavash
  • 14,244
  • 5
  • 52
  • 80