我不明白为什么我的C编译器会抛出一个直接的错误。根据{{3}},我初始化了所有内容,或者至少我认为我做了。然而,我仍然被抛出一个直接的错误。它一直在说expected int (*)(const struct dirent *) but argument is of type 'int (*)(struct dirent *)'
我的代码:
extern int alphasort();
int count, i;
struct direct **files;
if(!(getcwd(pathname, sizeof(pathname))))
{
die("Error getting pathname\n");
}
printf("Current Working Directory = %s\n", pathname);
count = scandir(pathname, &files, file_select, alphasort);
if (count < 0)
{
die("No files in this directory.\n");
}
else
{
printf("Number of files = %d\n", count);
for (i = 1; i < count+1; i++)
{
printf("%s ",files[i-1]->d_name);
printf("\n");
}
return 1;
}
pathname = char pathname[MAXPATHLEN];
file_select =
int file_select(struct direct *entry)
{
if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0))
return (FALSE);
else
return (TRUE);
}
答案 0 :(得分:4)
您需要更改回调函数,使其参数符合预期:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(![self.selectedIndexPaths containsObject:indexPath])
{
[self.selectedIndexPaths addObject:indexPath];
}
else
{
[self.selectedIndexPaths removeObject:indexPath];
}
[tableView reloadData];
NSLog(@"%ld", (long)indexPath.row);
}