user916367
user916367

Reputation:

Incompatible pointer types Xcode

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

static NSString *cellID = @"customCell";

NewCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

Upvotes: 5

Views: 7939

Answers (2)

Daniel A. White
Daniel A. White

Reputation: 190897

You have to cast it.

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

Upvotes: 3

Pontus Granström
Pontus Granström

Reputation: 1089

[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];

Upvotes: 12

Related Questions