I can't see why this doesn't work. The following code block throws a warning at the addObject line: "Passing argument 1 of 'taskWithText:dueDate:' from incompatible pointer type"
- (id)init{
self = [super init];
if (self) {
taskListArray = [[NSMutab开发者_如何学PythonleArray alloc] init];
[taskListArray addObject:[AFLTask taskWithText:"@Helloski" dueDate:[NSDate dateWithNaturalLanguageString:@"12/31/12"]]];
}
return self;
}
It's so simple I don't see why it doesn't work. It seems to match my method:
- (id)initWithText:(NSString *)newText dueDate:(NSDate *)newDueDate{
if(self = [super init]){
taskText = [newText retain];
taskDue = [newDueDate retain];
taskCompleted = NO;
}
return self;
}
+ (id)taskWithText:(NSString *)newText dueDate:(NSDate *)newDueDate{
return [[[AFLTask alloc] initWithText:newText dueDate:newDueDate] autorelease];
}
What is going on here? I'm pretty new to Objective-C (but not programming in general) and so I'm still trying to wrap my head around pointers -- but shouldn't this work?
You're going to kick yourself:
"@Helloski"
should be
@"Helloski"
精彩评论