The effect is the same, by the time your control awakes from nib you'll have your accessibilityIdentifier
/Label
/etc
set up.
Not sure if one way is "officially" preferred over another but I'd recommend using Accessibility section at least for the following reasons:
- You are sfae frmo tpyos.
- User-defined runtime attributes are there for you set up your custom properties. For standard attributes Apple takes care of you by giving you the specific, logically grouped knobs and input fields.
- What if you specify both? Which one do you expect to be the final value?
- Answer: the custom one, but I'm not sure that's documented anywhere and therefore you shouldn't rely on that. And even if it is documented, I'd still avoid such redundancy :-)
- Custom (user-defined) properties are set via KVC, which adds some (negligible) overhead, whereas for Accessibility section there seems to be some shortcut¹ (note the absence of
setValue:forKey:
):
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x000000010efe09fb AccessibilityProbe`-[MyButton setAccessibilityIdentifier:](self=0x00007fbb765231d0, _cmd="setAccessibilityIdentifier:", accessibilityIdentifier=@"testID") at MyButton.m:14
frame #1: 0x0000000112e35538 UIKitCore`-[UIRuntimeAccessibilityConfiguration applyConfiguration] + 153
frame #2: 0x0000000110825cfd CoreFoundation`-[NSArray makeObjectsPerformSelector:] + 317
frame #3: 0x0000000112e33258 UIKitCore`-[UINib instantiateWithOwner:options:] + 1717
¹ Again, implementation details are not something to rely on.