-1

Application getting crash.

I have added custom cell.While scrolling application getting crash and getting error:

"UIView setTableViewStyle unrecognized selector sent to instance XXXXXX"

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if(tableView==tableviewDetail)
    {
        static NSString *CellIdentifier_1 = @"Cell";
        CustomCASADetailCell *cell = (CustomCASADetailCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_1];

          if (cell == nil)
        {

           NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCASADetailCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];


            if([strCallingView isEqualToString:@"CreditCard"])
            {
                if ([indexPath row] % 2==0)
                    cell.contentView.backgroundColor=[UIColor whiteColor] ;
                else
                    cell.contentView.backgroundColor =[UIColor colorWithRed:205.0f/255.0f green:201.0f/255.0f blue:201.0f/255.0f alpha:0.6f];
            }
            else
            {
                if ([indexPath row] % 2==0)
                    cell.contentView.backgroundColor=[UIColor whiteColor] ;
                else
                    cell.contentView.backgroundColor =[UIColor colorWithRed:255.0f/255.0f green:239.0f/255.0f blue:213.0f/255.0f alpha:0.6f];
            }

        }

        NSArray *toplavelobject=[[NSBundle mainBundle]loadNibNamed:@"CustomCASADetailCell" owner:self options:nil];
        for(id c in toplavelobject)
        {
            if ([c isKindOfClass:[UITableViewCell class]])
            {
                cell=(CustomCASADetailCell *) c;

                break;
            }
        }

        if([strCallingView isEqualToString:@"CreditCard"])
        {
            if([maCreditCardDetailKey count]>0 && [maCreditCardDetailValue count]>0)
            {
                cell.lblName.text=[maCreditCardDetailKey objectAtIndex:indexPath.row];
                cell.lblDescription.text=[maCreditCardDetailValue objectAtIndex:indexPath.row ];
            }

        }
        else if([strCallingView isEqualToString:@"Account"])
        {
            if([maAccountDetailKey count]>0 && [maAccountDetailValue count]>0)
            {
                cell.lblName.text=[maAccountDetailKey objectAtIndex:indexPath.row];
                cell.lblDescription.text=[maAccountDetailValue objectAtIndex:indexPath.row ];
            }

        }
        return cell;
    }

        else if(tableView==tableviewMiniStatement)
    {
        static NSString *CellIdentifier_2 = @"Cell";

       MinistatementTableCell *cell = (MinistatementTableCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_2];

        if (cell == nil)
        {

         cell = [[MinistatementTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] ;

            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MinistatementTableCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];

        }

        cell.lblDescription.adjustsFontSizeToFitWidth=NO;
        cell.lblDescription.numberOfLines=4;
        cell.lblDescription.lineBreakMode=UILineBreakModeWordWrap;

       MiniStatement *objMiniStatement=[[MiniStatement alloc]init];
       if([marrAccountMinistatement count]>0)
       {

           if (tableView.tag==0)


           {
                objMiniStatement=[marrAccountMinistatement objectAtIndex:indexPath.row];

           }
        else
            {
               objMiniStatement=[marrAccountMinistatement objectAtIndex:((tableView.tag*5)+indexPath.row)];
            }

                cell.lblTransactionDate.text=objMiniStatement.strATAccountPostDate;//set transaction date here

                cell.lblValueDate.text=objMiniStatement.strATAccountPostDate ;

                cell.lblDescription.text=objMiniStatement.strATNaration;


                cell.lblAmount.text=[NSString stringWithFormat:@"%@  %@",lblCurrency.text,objMiniStatement.strATTransactionAmount];


            }
      }

        return cell;

    }



    else if(tableView==tableviewCCUnbilledTransaction)
    {
        static NSString *CellIdentifier_3 = @"Cell";
        CCUnbilledTransactionCell *cell = (CCUnbilledTransactionCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier_3];

        if (cell == nil)
        {



            NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CCUnbilledTransactionCell" owner:self options:nil];

            cell = [topLevelObjects objectAtIndex:0];

        }


        NSArray *toplavelobject=[[NSBundle mainBundle]loadNibNamed:@"CCUnbilledTransactionCell" owner:self options:nil];
        for(id c in toplavelobject)
        {
            if ([c isKindOfClass:[UITableViewCell class]])
            {
                cell=(CCUnbilledTransactionCell *) c;

                break;
            }
        }

        cell.lblDescription.adjustsFontSizeToFitWidth=NO;
        cell.lblDescription.numberOfLines=4;
        cell.lblDescription.lineBreakMode=UILineBreakModeWordWrap;

        CardMiniStatement *objCardMiniStatement=[[CardMiniStatement alloc]init];
        if([marrCCUnbilledTransactionRecordShown count]>0)
        {
            if (tableView.tag==0)
            {
                objCardMiniStatement=[marrCCUnbilledTransactionRecordShown objectAtIndex:indexPath.row];
            }
            else
            {
                objCardMiniStatement=[marrCCUnbilledTransactionRecordShown objectAtIndex:((tableView.tag*5)+indexPath.row)];//Sarita 28May
                          }
            if(objCardMiniStatement!=nil)
            {
                cell.lblCreditCardNo.text=[FormatData FormatCreditCardNumber:objCardMiniStatement.strCardNumber];

                cell.lblTransactionDate.text=objCardMiniStatement.strTransactionDate ;
                cell.lblPostDate.text=objCardMiniStatement.strPostDate;
                cell.lblDescription.text=objCardMiniStatement.strTransactionDetail;
                cell.lblAmount.text=objCardMiniStatement.strTransactionAmount;
            }
        }

        return cell;
    }



}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Neha
  • 27
  • 1
  • 5
  • You can't close or exit the app... http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW27 – Kumar KL Jun 27 '13 at 05:28
  • force to crash your app :) – adali Jun 27 '13 at 05:33
  • It's just a warning, that we shouldn't use `exit(0)` in code. The good solution is to submit to app-store with your current package having close button and see if the accept it or not. There is one of my app that has been accepted which uses exit(0) – Inder Kumar Rathore Jun 27 '13 at 05:43
  • ok.Can suggest me any other way? – Neha Jun 27 '13 at 05:56
  • Why do you think you need to exit the app? Let the user decide. They can press the Home button if they want to leave your app. – rmaddy Jun 27 '13 at 06:06
  • Check the technical Q&A [here](https://developer.apple.com/library/ios/#qa/qa2008/qa1561.html) – maqjav Jun 27 '13 at 05:27
  • you can not forcefully close any ios applicaton. [Here is your answer](http://developer.apple.com/library/ios/#qa/qa1561/_index.html) Thanks, – sagarcool89 Jun 27 '13 at 05:28

2 Answers2

0

Q: How do I programmatically quit my iOS application?

A: There is no API provided for gracefully terminating an iOS application.

In iOS, the user presses the Home button to close applications. Should your application have conditions in which it cannot provide its intended function, the recommended approach is to display an alert for the user that indicates the nature of the problem and possible actions the user could take — turning on WiFi, enabling Location Services, etc. Allow the user to terminate the application at their own discretion.

Warning: Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen. Additionally, data may not be saved, because -applicationWillTerminate: and similar UIApplicationDelegate methods will not be invoked if you call exit.

If during development or testing it is necessary to terminate your application, the abort function, or assert macro is recommended.

Source: iOS Developer Library Technical Q&A QA1561

rog
  • 5,351
  • 5
  • 33
  • 40
  • Can you provide me any suggestion to close the application.while click on CLOSED button – Neha Jun 27 '13 at 05:52
0

You can also use the abort();.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Mike
  • 737
  • 1
  • 6
  • 14
  • 1
    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion – Prashant Tukadiya Sep 08 '17 at 14:11