I have defined the following interface:
@interface ListNode : Object
{
@private
int value;
ListNode* next;
}
- (id) value: (int) value_value; //Don't judge me, okay?
- (int) value;
- (id) next: (ListNode*) next_value;
- (ListNode*) next;
@end
And the following implementation:
@implementation ListNode
- (id) value: (int) value_value
{
value = value_value;
return self;
}
- (int) value
{
return value;
}
- (id) next: (ListNode*) next_value
{
next = next_value;
return self;
}
- (ListNode*) next
{
return next;
}
@end
Then finally in my main method I am trying to do this:
ListNode *root;
root = [ListNode new];
When I compile the program I don't get any errors but I do get a warning that says:
class method '+new' not found (return defaults to 'id') [-Wobjc-method-access]
I tried to run the program and I get a segfault and I can't figure out where it is. I looked up the wikibook on this and it had almost the exact same syntax as me so I don't understand what's wrong.