How to access Object ID Identity attribute

2019-06-15 03:39发布

HI guys.

Part 1. In the IB under Identity tab you can find an attribute called "Object ID". I can not find a way to get hold of this ID from code. Oh, and I know about the tag attribute but it's not what I need.

Part 2. I essentially would like to get the unique object ID for a UIComponent that was touched on the sceen. I already have the UITouch object.

Thanks.

3条回答
迷人小祖宗
2楼-- · 2019-06-15 04:14

For UIView I normally use the tag property.

- (IBAction) buttonPressedid) sender {
NSLog(@"tag: %i", [sender tag]);
}

I'm pretty sure you can set the tag property in IB :)

查看更多
啃猪蹄的小仙女
3楼-- · 2019-06-15 04:20

use tags instead of the IB Object ID. As far as I know this object ID is only used in interface builder.

You can set the tag in the Attributes tab.

查看更多
我命由我不由天
4楼-- · 2019-06-15 04:23

The Object ID in Interface Builder is only an internal book-keeping value used by IB when deserializing/serializing XIB files, and does no longer exist when the Application runs.

You want to use tag, or alternately, a property/outlet.

查看更多
登录 后发表回答