"zero" reserved tag number in cocoa?

I want to know if zero is a reserved tag number in cocoa.

I ask because I created UIButtons in a for loop from 0 to n and evaluated the loop index as every button tag created.

Then, when I tried to reference using viewWithTag and tried to change the property, I get a sigbart error for the button tag zero. All other buttons work fine.

To make my code work, I had to create buttons using for 1 - n + 1

+3
source share
2 answers

tag is an integer instance variable in subclasses of UIView and like any other ivar integer, by default it is initialized to 0.

, subview, , 0, subviews viewWithTag:, - , UIButton, , , , ( ?) .

+8

documentation . (.. UIViews .. .) , , SIGBART , ( ) viewWithTag .

1.

+1

Source: https://habr.com/ru/post/1784963/


All Articles