넘어 인덱스 2 : 난 내가 추출하고이 LeavemanagementViewController.mjQuery과 경계 종료 응용 프로그램 'NSRangeException'- [__ NSArrayM objectAtIndex :] : 다음과 같은 코드에 문제가 경계 [0 .. 1] '
에게 있습니다 및 서버에서 xml에서 데이터를로드합니다. 총 요소 수는 배열에 따라 다릅니다.
-(void)RejectActionPressed:(id)sender
{
if ([approve1role.text isEqualToString:datarole.text])
{
UIButton *buttn2=(UIButton*)sender;
NSLog(@"bttn.tag==%i",buttn2.tag);
StudentClass *student = (StudentClass *) [arrayitems objectAtIndex:buttn2.tag];
NSLog(@"student name= %@ \n leavecode %@ \n joining dat=%@",student.employeeName,student.leavecode,student.joiningdate);
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Alert" message:@" " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alert1.tag = buttn2.tag;
alert1.tag = kAlertViewTwo; CGRect frame = CGRectMake(14, 45, 255, 23);
remarkstext = [[UITextField alloc] initWithFrame:frame];
remarkstext.placeholder = @"Name";
remarkstext.backgroundColor = [UIColor whiteColor];
remarkstext.autocorrectionType = UITextAutocorrectionTypeDefault;
remarkstext.keyboardType = UIKeyboardTypeAlphabet;
remarkstext.returnKeyType = UIReturnKeyDone;
remarkstext.clearButtonMode = UITextFieldViewModeWhileEditing;
[alert1 addSubview:remarkstext];
[alert1 show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == kAlertViewOne)
{
if (buttonIndex==1)
{
NSLog(@"%@",remarkstext.text);
remarksoutput.text = remarkstext.text;
NSLog(@" The Alertview%@",remarksoutput.text);
[self callWebservice:alertView.tag];
}
else if (buttonIndex==0)
{
NSLog(@"cancel");
}
}
if(alertView.tag == kAlertViewTwo)
{
if (buttonIndex==1)
{
NSLog(@"%@",remarkstext.text);
remarksoutput.text = remarkstext.text;
NSLog(@" The Alertview%@",remarksoutput.text);
[self callRejectWebservice:alertView.tag];
}
else if (buttonIndex==0)
{
NSLog(@"cancel");
}
}
}
-(void)callRejectWebservice:(int)tag
{
if ([approve1role.text isEqualToString:datarole.text])
{
StudentClass *student = (StudentClass *) [arrayitems objectAtIndex:tag]; // Here is my error *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
NSLog(@"student name= %@ \n leavecode %@ \n joining dat=%@",student.employeeName,student.leavecode,student.joiningdate);
}
if ([approve2role.text isEqualToString:datarole.text])
{
StudentClass *student = (StudentClass *) [arrayitems objectAtIndex:tag];
NSLog(@"student name= %@ \n leavecode %@ \n joining dat=%@",student.employeeName,student.leavecode,student.joiningdate);
}
if ([approve3role.text isEqualToString:datarole.text])
{
StudentClass *student = (StudentClass *) [arrayitems objectAtIndex:tag];
NSLog(@"student name= %@ \n leavecode %@ \n joining dat=%@",student.employeeName,student.leavecode,student.joiningdate);
}
}
제발 나를 도와주세요.
위의 코드를 추가하면 0 indexpath는 indexpath 1 값의 값을 표시합니다. –
Button2.tag의 가치가 무엇인지 말해 주시겠습니까? –
나는 tablecell에 버튼을 추가했습니다. // 버튼을 만들어 셀에 추가합니다. Reject button UIButton * button2 = [UIButton buttonWithType : UIButtonTypeRoundedRect]; button2.tag = indexPath.row; [button2 addTarget : 자기 동작 : @selector (RejectActionPressed :) forControlEvents : UIControlEventTouchDown]; button2.frame = CGRectMake (720.0f, 85.0f, 100.0f, 25.0f); [cell addSubview : button2]; –