从 NSMutable 数组中检索整数数据
我在从 NSMutable 数组获取整数值时遇到问题。我在屏幕上有几个具有匹配标签属性值的按钮(button1 的标签值为 1 等)。当按下按钮时,我将数字标签值添加到 NSMutable 数组中。稍后,我想循环访问对象以查看按下哪些值来构建查询。但是,我在循环中收到 SIGABRT 错误。
//pairNumber is the 'tag' value from a button
-(void) numberSearchArray:(NSInteger)pairNumber;
{
[self.queryPairs addObject:[NSNumber numberWithInt: pairNumber]];
}
//***************************
-(void)buildQuery:(BOOL *)function numberToUse:(NSInteger)number
{
//other code not shown
int pair_values [6];
int compare_total = [queryPairs count];
for (int x = 0; x<=compare_total-1; x++){
pair_values[x] = (NSUInteger)[queryPairs objectAtIndex:x]; //SIGABRT error
//code continued...
}
I am having an issue getting integer values form an NSMutable array. I have several buttons on the screen with a matching tag property value (button1 has a tag value of 1, etc.). When a button is pressed, I add the numeric tag value to the NSMutable array. Later, I want to loop through the objects to see what values are pressed to build a query. However, Iget a SIGABRT error in the loop.
//pairNumber is the 'tag' value from a button
-(void) numberSearchArray:(NSInteger)pairNumber;
{
[self.queryPairs addObject:[NSNumber numberWithInt: pairNumber]];
}
//***************************
-(void)buildQuery:(BOOL *)function numberToUse:(NSInteger)number
{
//other code not shown
int pair_values [6];
int compare_total = [queryPairs count];
for (int x = 0; x<=compare_total-1; x++){
pair_values[x] = (NSUInteger)[queryPairs objectAtIndex:x]; //SIGABRT error
//code continued...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你需要做:
you need to do:
您没有对pair_values进行边界检查,您的queryPairs数组中是否有超过6个项目?
You're not bounds checking pair_values, do you have more than 6 items in your queryPairs array?