Triz
Triz

Reputation: 767

Can I set the tag property on a UIView subclass?

I've got a UIView subclass called CardView, and created an instance like so:

CardView *newCard = [[CardView alloc] initWithFrame:CGRectMake(x,y,w,h)];

And then I've tried to set the view's tag like this:

newCard.tag = 1;

But that doesn't seem to be actually setting the tag for that view. If I set a breakpoint around there, and do

po newCard.tag

in the debugger, it says

error: property 'tag' not found on object of type 'CardView *'

Shouldn't I be getting a tag property as part of the UIView subclass?

Upvotes: 0

Views: 2814

Answers (1)

Seva Alekseyev
Seva Alekseyev

Reputation: 61396

The debugger console does not understand the Objective C property syntax. Instead, do this in the source file:

NSLog(@"%d", newCard.tag);

and you'll see it in the console.

The debugger understands methods though, although it gets confused about datatypes. This debugger command would work:

p (int)[newCard tag]

That's about as objective as GDB gets.

Upvotes: 3

Related Questions