I have this code:
likeButton.tag = spik._id;
NSLog(@"spik ID=%@ likebtn.tag=%@",spik._id,likeButton.tag);
NSLog(@"%@", likeButton);
where spik._id
is NSInteger
And this is the output:
2012-03-11 19:35:37.751 KwikSpik[44277:ce03] spik ID=39975 likebtn.tag=39975
2012-03-11 19:35:37.752 KwikSpik[44277:ce03] <<UIButton: 0xd178b60; frame = (20 12604; 30 30); opaque = NO; tag = 90793136; layer = <CALayer: 0xd1788d0>>
You see that likeButton.tag = 39975
here but when I log the button, its tag is 90793136
.
if I write NSLog(@"spik ID=%@ likebtn.tag=%d",spik._id,likeButton.tag);
then I get
012-03-11 23:27:38.290 KwikSpik[45326:ce03] spik ID=39975 likebtn.tag=87582784
Are these different presentations of one number or different values? Why are these values different?
Later if I write
NSLog(@"tag d %d",sender.tag);
NSLog(@"tag @ %@",sender.tag);
where sender is likeButton
then first NSLog
outputs 87582784
and second crashes with EXC_BAD_ACCESS (code = 1, address = 0x30...)
What's happening? Why there're different values in likeButton.tag
and spik._id
- or they just look like different?
Why NSLog first time outputted likeButton.tag
with %@
and the second time it crashed?