开发者

Incompatible pointer type with NSDate

开发者 https://www.devze.com 2023-03-04 19:57 出处:网络
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\"

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号