1

Thanks in advance, In my application i am trying to display second view controller with tableviewdidselectrowatindexpath method. below is my code, its working properly if i don't use autorelease, but if i use autorelease it gives error, i tried using NSZombie Enable for finding Error, it gives some error regarding this Autorelease. the same method i am using in other class files of same project, but that time it is working properly.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {

  if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
   {
    if ([[UIScreen mainScreen] bounds].size.height == 568)
    {
        CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewController"bundle:nil]autorelease];
        cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
        cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
        cvc.isGroup = @"no";
        [self.navigationController pushViewController:cvc animated:YES];


    }

    else
    {

       CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewControlleriPhone4"bundle:nil]autorelease];
        cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
        cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
        cvc.isGroup = @"no";
        [self.navigationController pushViewController:cvc animated:YES];

    }

}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
     CreateMessageViewController *cvc = [[[CreateMessageViewController alloc]initWithNibName:@"CreateMessageViewControlleriPad"bundle:nil]autorelease];
    cvc.Username = [arrayUserName objectAtIndex:indexPath.row];
    cvc.UserId = [arrayUserID objectAtIndex:indexPath.row];
    cvc.isGroup = @"no";
    [self.navigationController pushViewController:cvc animated:YES];

 }

}

the same method i used in other class file, but that don't give any error or crash., that code is as below.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
   {
    if (StudioManger)
{

    NSLog(@"You can edit Schedule");
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        if ([[UIScreen mainScreen] bounds].size.height == 568)
        {
            EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewController" bundle:Nil]autorelease];
            esvc.StudioID = myStudioID ;
            esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
            esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
            esvc.Date = [arraydate objectAtIndex:indexPath.row];
            esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
            esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
            esvc.Day = [arrayDay objectAtIndex:indexPath.row];
            esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
            esvc.StudioName = StudioName ;
            [self.navigationController pushViewController:esvc animated:YES];

        }

        else
        {
            EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewControlleriPhone4" bundle:Nil]autorelease];
            esvc.StudioID = myStudioID ;
            esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
            esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
            esvc.Date = [arraydate objectAtIndex:indexPath.row];
            esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
            esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
            esvc.Day = [arrayDay objectAtIndex:indexPath.row];
            esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
            esvc.StudioName = StudioName ;
            [self.navigationController pushViewController:esvc animated:YES];


        }

    }
    else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        EditScheduleViewController *esvc = [[[EditScheduleViewController alloc]initWithNibName:@"EditScheduleViewControlleriPad" bundle:Nil]autorelease];
        esvc.StudioID = myStudioID ;
        esvc.Fromtime = [arrayfromtime objectAtIndex:indexPath.row];
        esvc.Totime = [arraytotime objectAtIndex:indexPath.row];
        esvc.Date = [arraydate objectAtIndex:indexPath.row];
        esvc.Grouptype = [arraygroupname objectAtIndex:indexPath.row];
        esvc.DanceType = [arraydancetype objectAtIndex:indexPath.row];
        esvc.Day = [arrayDay objectAtIndex:indexPath.row];
        esvc.scheduleid = [arrayScheduleID objectAtIndex:indexPath.row];
        esvc.StudioName = StudioName ;
        [self.navigationController pushViewController:esvc animated:YES];

      }

     }
    else
    {

    }


    }

please some one help me, Note, i am not using ARC . and working in Xcode 5

The error i get through NSZombie is as below,

2013-10-28 17:12:34.287 Dance Program[3855:a0b] * -[AppDelegate performSelector:withObject:withObject:]: message sent to deallocated instance 0xa077590

rmaddy
  • 314,917
  • 42
  • 532
  • 579
zak
  • 65
  • 1
  • 1
  • 9
  • which line of code gives you error? – Kreiri Oct 28 '13 at 11:31
  • it gives crash exact after pressing back button in CreateMessageMainViewController. the coding of back button is as below -(IBAction)ClickToBack:(id)sender { [self.navigationController popViewControllerAnimated:YES]; } – zak Oct 28 '13 at 11:35
  • @Kreiri : i edited my que nd listed error, which i get through NSZombie Enable . – zak Oct 28 '13 at 11:47

1 Answers1

0

What worked best for me when I ran into similar problems recently was the following:

Under under Project->Edit Active Executable -> Arguments tab -> Environment variables section I added and set to YES the following variables: NSAutoreleaseFreedObjectCheckEnabled, NSZombieEnabled and NSDebugEnabled.

Under the Run menu, I selected Enable Guard Malloc.

With these settings the debugger provided more hints on what's wrong with my code.

I found these tips Here

And also check this link ViewController respondsToSelector: message sent to deallocated instance (CRASH)

Good luck...

Community
  • 1
  • 1
Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
  • Thank you .. sorry for late reply.. for this problem temporary i tried below solution. i import CreateMessageViewController.h file in CreateMessageMainViewController , and create its object in .h file. than did the same thing just put that object release part in -(void)dealloc method. and that thing works now.. – zak Nov 07 '13 at 11:06