Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Expected ; at end of declaration list - Class not recognized as type

Here is my viewcontroller.h file:

#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import <CoreLocation/CoreLocation.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreMedia/CoreMedia.h>
#import <ImageIO/ImageIO.h>
#import <CoreVideo/CoreVideo.h>


@interface ViewController : UIViewController <UINavigationControllerDelegate,  CLLocationManagerDelegate>

@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
@property(nonatomic, weak) IBOutlet UIImageView *selectedImageView;
@property(nonatomic, retain) IBOutlet UIImageView *vImage;
@property(nonatomic, retain) AVCaptureStillImageOutput *stillImageOutput;

- (IBAction)photoFromAlbum;
- (IBAction)photoFromCamera;
- (IBAction)saveImageToAlbum;
- (IBAction)segueToChoosePhotoTypeViewController;

@end

The line:

@property(nonatomic, retain) AVCaptureStillImageOutput *stillImageOutput;

is generating the following issue:

Expected ; at end of declaration list.

Xcode isn't recognizing AVCaptureStillImageOutput as a class as it remains black and doesn't suggest it as a type, and the "Fix-it" wants to insert the ; right after AVCaptureStillImageOutput.

However, if I try to use declare AVCaptureStillImageOutput as a type in viewDidLoad of my viewController.m file, it recognizes it and allows it as a type. Also, the rest of the AVFoundation classes are being recognized in the code there.

The framework is there, I'm just having an issue with this @property declaration.

like image 233
OdieO Avatar asked Jan 16 '13 18:01

OdieO


Video Answer


2 Answers

In your line

@property(nonatomic, retain) AVCaptureStillImageOutput *stillImageOutput;

you have some invisible characters between AVCaptureStillImageOutput and *stillImageOutput. If I paste this line into the vi editor, it looks like this:

@property(nonatomic, retain) AVCaptureStillImageOutput<feff><feff><feff><feff><feff> *stillImageOutput;

(U+FEFF is a Unicode Byteorder marker, and it looks like a normal space in Xcode, even if "Show Invisibles" is activated).

Deleting and re-inserting the space fixes the problem.

like image 199
Martin R Avatar answered Nov 03 '22 00:11

Martin R


Go to the Editor menu, select Show Invisibles. Note that you have plenty of invisible, non printable characters between the AVCaptureStillImageOutput and the *. Delete everything between these two and finally put there a single space again. Those invisible characters, even though not printable, were taken as part of your class name. Once you are done, you can select Hide Invisibles again. Be careful when copy/pasting code, you even copy/pasted those "bad characters" into your SO question above.

like image 23
Mecki Avatar answered Nov 03 '22 00:11

Mecki