1. The simplest way is to use the button tag to pass the value. But this is not a recommended approach. . And only int type can be passed. 2. You can customize a button to inherit UIButton and use data as an attribute. (Recommended) 3. You can add a category. Use runtime Associative technology to force the addition of a data attribute. (Key recommendation) Associative technology, you can see the Associative node demo in this article: click to enter
1. The simplest way is to use the button tag to pass the value. But this is not a recommended approach. . And only int type can be passed.
2. You can customize a button to inherit UIButton and use data as an attribute. (Recommended)
3. You can add a category. Use runtime Associative technology to force the addition of a data attribute. (Key recommendation)
Associative technology, you can see the Associative node demo in this article: click to enter
plusBtn.tag = indexPath.row;
in plusEvent:Then sender.tag