【发布时间】:2011-06-28 23:05:57
【问题描述】:
这可以在 Objective-C 中使用吗? Pass two integers as one integer
如果是这样,我该如何使用NSInteger?
我之所以问,是因为我想从 NSUIntegers row 和 section 的 UITableView 中计算唯一的 NSInteger tag?
看,我正在处理一个UITableViewController,它有三个部分,每个部分都有多行。每行都有一个UISwitch,每个UISwitch 都链接到相同的目标-操作方法switchAction:。
在switchAction:,我的计划是检查sender的tag以找出UITableView的UISwitch的NSIndexPath(section&row)。
所以,我想要两种方法:
+ (NSInteger)integerFromInteger1:(NSInteger)int1 integer2:(NSInteger)int2;
+ (NSIndexPath *)indexPathFromInteger:(NSInteger)integer;
用 C 编写的第一种方法可能效果更好。如果您愿意,也可以使用。
【问题讨论】:
-
我不知道你为什么要这样使用标签,但你已经链接到另一个回答这个问题的 SO 问题。
-
@Kevin Ballard,好的,你会采取什么方法来确定是哪个交换机发送了
switchAction:消息? -
交换机将自己作为第一个参数发送给
switchAction:。你已经知道了,因为你说你的计划是检查sender的tag(sender是开关)。 -
@Kevin Ballard,对。抱歉,我的意思是how do you figure out the index path of the
UISwitch?谢谢你的建议。我想我找到了更好的方法。
标签: objective-c uitableview uiview tags