-1

I have a PSCollectionView that I have used once. Now i want to use it again in another ViewController but when I begin to implement it i get Duplicate interface definition for class 'PSCollectionView' and Property has a previous declaration everywhere. I have no idea what to do.

Like this :

self.waterflowView = [[PSCollectionView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
self.waterflowView.delegate = self; // This is for UIScrollViewDelegate
self.waterflowView.collectionViewDelegate = self;
self.waterflowView.collectionViewDataSource = self;
self.waterflowView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.waterflowView.delaysContentTouches = NO;

if ([[UIDevice currentDevice].model isEqualToString:@"iPhone"]) {
    self.waterflowView.numColsPortrait = 1;
    self.waterflowView.numColsLandscape = 2;
} else {
    self.waterflowView.numColsPortrait = 1;
    self.waterflowView.numColsLandscape = 2;
}

[self.mainView addSubview:waterflowView];

When i add this code for the second UIScrollView I want to do

@interface KerkoViewController : UIViewController <UIScrollViewDelegate, PSCollectionViewDataSource, PSCollectionViewDelegate>

I get error in the PSCollectionView.h file in these lines:

@interface PSCollectionView : UIScrollView
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, assign, readonly) CGFloat colWidth;
@property (nonatomic, assign, readonly) NSInteger numCols;
@property (nonatomic, assign) NSInteger numColsLandscape;
@property (nonatomic, assign) NSInteger numColsPortrait;
@property (nonatomic, unsafe_unretained) id <PSCollectionViewDelegate> collectionViewDelegate;
@property (nonatomic, unsafe_unretained) id <PSCollectionViewDataSource> collectionViewDataSource;

and the import statements

#import <UIKit/UIKit.h>
#import "QuartzCore/QuartzCore.h"#include <mach/mach.h>
#include <mach/mach_time.h>
#include "PSCollectionView.h"
#import "WaterflowViewCell.h"
#import "MWPhotoBrowser.h"
Elgert
  • 470
  • 2
  • 5
  • 19

1 Answers1

1

You should use #import directives rather than #include directives otherwise the compiler will try to include the header files again which would lead to the error message you're getting.

With #import the compiler will handle this by itself.

snod
  • 2,442
  • 3
  • 20
  • 22