Reputation: 18488
Recently I downloaded the open source project zbar, the project itself it not really relevant to my question, what I still can't figure out is how in his viewcontroller he is able to do this:
//
// EmbedReaderViewController.h
// EmbedReader
//
// Created by spadix on 5/2/11.
//
#import <UIKit/UIKit.h>
@interface EmbedReaderViewController
: UIViewController
< ZBarReaderViewDelegate >
{
ZBarReaderView *readerView;
UITextView *resultText;
ZBarCameraSimulator *cameraSim;
}
@property (nonatomic, retain) IBOutlet ZBarReaderView *readerView;
@property (nonatomic, retain) IBOutlet UITextView *resultText;
@end
That is it, that is the whole file, how can he see the delegate and the ZBarReaderView and ZBarCameraSimulator, without importing anything???.
My implementation is working, but I of course have to import the files, and as I was looking at the example, it really caught my attention that he was not importing anything... how is that possible??
Upvotes: 0
Views: 396
Reputation: 138201
Projects usually have a pch
file (pre-compiled/prefix header) in them; this file is automatically included in every other code file of the project. If the pch
file contains an #import
to the protocol file, then every file in the project will be aware of it.
Upvotes: 7
Reputation: 16448
He must have either a forward declaration or the import in the prefix header file, which is a file in the project ending in .pch
, that is automatically imported by all source files in the project.
Upvotes: 2