I've been working on an app that uses a collection view, and I'm creating a custom view cell (Category View Cell) which is a subclass of UICollectionViewCell. I also wanted to create a subclass of the custom view cell (LinkCell). I've been searching for a while now and I cannot find why I am getting the error "Cannot find interface declaration of 'CategoryViewCell', superclass of 'LinkCell'"
//CategoryViewCell.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
@class ViewController;
@interface CategoryViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *image;
@property (nonatomic) ViewController *parentView;
@property (nonatomic) NSString *cellName;
@end
//CategoryViewCell.m
#import "CategoryViewCell.h"
@implementation CategoryViewCell
@end
//LinkCell.h
#import <UIKit/UIKit.h>
#import "CategoryViewCell.h"
#import "PJP Webview.h"
@interface LinkCell : CategoryViewCell //Error here
@property (nonatomic) NSString *username;
@property (nonatomic) NSString *password;
@property (nonatomic) NSString *urlToLink;
@property (nonatomic) NSString *urlToLinkS;
@property (nonatomic) NSString *urlToLinkP;
@property (nonatomic) NSString *urlToLinkT;
@property (nonatomic) NSString *body;
-(IBAction)celltapped:(id)sender;
@end
//LinkCell.m
#import "LinkCell.h"
@implementation LinkCell
@synthesize urlToLink, username, password, image, cellName, parentView;
-(IBAction)celltapped:(id)sender {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *launchString = [NSString stringWithFormat:@"hasLaunched%@Before", self.cellName];
BOOL hasLaunchedCellBefore = [userDefaults boolForKey:launchString];
if (!hasLaunchedCellBefore) {
// first time launch code
hasLaunchedCellBefore = TRUE;
[userDefaults setBool:hasLaunchedCellBefore forKey:launchString];
[userDefaults synchronize];
PJP_Webview *vc = [parentView.storyboard instantiateViewControllerWithIdentifier:@"vc"];
vc.currentCell = self;
[parentView presentViewController:vc animated:YES completion:nil];
}
else {
}
}
@end
Could someone please show me where my error is?
I just solved it; ViewController.h uses the CategoryViewCell and I imported the .h and used the @class for the ViewController property on CategoryViewCell.h. Only the @class was necessary; I guess some sort of circular dependency was created. The weird part was that CategoryViewCell.h didn't have the errors, its subclass did. Thanks to anyone who answered!