Reputation: 785
I have set the tag in the method cellForRowAtIndexPath
as
cell.noOfCommentsButton.tag=indexPath.row;
where noOfCommentsButton
is my UIButton.
And i have defined IBAction for this button as:
- (IBAction)showComments:(BlogCell *)sender{
int tag=[(UIButton *)sender.noOfCommentsButton tag];
NSLog(@"The tag clicked:%d",tag);
}
where Blogcell is my class for the custom cell.
But i am getting an exception on the line NSLog(@"The tag clicked:%d",tag);
and I'm not sure why.
Upvotes: 0
Views: 135
Reputation: 4105
If you change the NSLog to this
NSLog(@"The tag clicked:%il",(long)tag);
If there's an error on the log that is.
Thanks, Jim
Upvotes: 0
Reputation: 119041
- (IBAction)showComments:(BlogCell *)sender{
This is wrong - the sender
is the button, not the cell. So it should be:
- (IBAction)showComments:(UIButton *)sender {
Upvotes: 1