不兼容的指针类型Xcode [英] Incompatible pointer types Xcode

查看:161
本文介绍了不兼容的指针类型Xcode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉对社区造成这样的负担,但我真的被困在这里。

Sorry to be such a burden on the community, but I really am stuck here.

语义问题:初始化 NewCustomCell *的指针类型不兼容,表达式类型为 UITableViewCell *

Semantic Issue: Incompatible pointer types initializing NewCustomCell * with an expression of type UITableViewCell *

static NSString *cellID = @"customCell";

NewCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];


推荐答案

[tableView dequeueReusableCellWithIdentifier:cellID ] 返回类型为 UITableViewCell * 的对象。如果您知道单元格将始终为 NewCustomCell * 类型,那么您可以告诉编译器期望使用强制转换。像这样:

[tableView dequeueReusableCellWithIdentifier:cellID] returns an object with type UITableViewCell *. If you know that the cell will always be of type NewCustomCell *, then you can tell the compiler to expect that with a cast. Like so:

NewCustomCell *cell = (NewCustomCell *) [tableView dequeueReusableCellWithIdentifier:cellID];

这篇关于不兼容的指针类型Xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆