I am initialising an object like so:
Project *Project = [[Project alloc] init];
Here's the code for the project class:
Project.h
#import <Foundation/Foundation.h>
@interface Project : NSObject
{
}
@property (nonatomic,assign) int projectID;
@property (nonatomic,strong) NSString *name;
@end
Project.m
#import "Project.h"
@implementation Project
@synthesize projectID, name;
@end
I'm getting the error No visible @interface for 'Project' declares the selector 'alloc'
when I try and initialise the object. How can I resolve this?
You seem to be trying to call a variable the exact same name as the class: Project *Project
. It's no wonder the compiler is getting confused!
Switch the variable name to lower case, Project *project
.
Never use the class name as an instance reference name.
GoddamnClass *GoddamnClass = [GoddamnClass new]; // will have problems
GoddamnClass *anInstanceOfGoddamnClass = [GoddamnClass new]; // works like a magic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With