0

i hope this is my last question for a while, I open a xib file via:

Results1 *myView1 = [[Results1 alloc]initWithNibName:@"Results1" bundle:nil];
    [self.view addSubview:myView1.view];

I have a button on the second xib file:

-(IBAction)Button1:(id)sender
{

    [self.view removeFromSuperview];
}

It crashes every time:

0xecf09b:  movl   8(%edx), %edi

I have the views linked

I am not sure if this is the problem:

@interface TestTypingToolViewController ()

{
    NSString *iResults1;
    NSString *iResults2;
    NSString *iResults3;
    NSString *iResults4;
    NSString *iResults5;
    NSString *Segment;
    NSDictionary *ResultsData;
}

@end

Thanks for all your help, everyone!

Tim
  • 115
  • 1
  • 2
  • 10
  • are you using ARC? what is the kind of error that causes the crash and on which line of your code (not the `movl`, too low level) does it occur? this info is available on the output console... – sergio Aug 10 '12 at 20:34
  • I dont know what ARC is but I am getting EXC_BAD_ACCESS(code=1, address=0xa0686703) – Tim Aug 10 '12 at 20:41

3 Answers3

2

The problem is I needed to turn off Automatic Reference Counting and everything worked.

Tim
  • 115
  • 1
  • 2
  • 10
0

It seems that you have got some issue with zombies, i.e., some object that is deallocated at some point but you try to access through some (dangling) reference. You could get more info about it by enabling zombies detection.

Actually, my guess is that you could fix this by storing Results1 *myView1 in a property of your class. Indeed, in your code, what happens is the myView1.view is retained by self.view; while myView1 is stored in a local variable, so the object (under ARC) should be deallocated when the variable is not used anymore. You have a mismatch here between the lifetimes of the two objects and this could lead to the crash.

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • So something like this in the .h file? @property (nonatomic,retain) Results1 *myView1 sorry I am new to objective c – Tim Aug 11 '12 at 01:48
  • With Zombie Detection on the error now is: calll 0x14fe884 ; symbol stub for: getpid EXC_BREAKPOINT (code=EXC_1386_BPT, subcode=0x0 – Tim Aug 11 '12 at 02:00
  • `@property (nonatomic,retain) Results1 *myView1` is what I though of (or `@property (nonatomic,strong) Results1 *myView1` if you using ARC)... don't forget to call `release` in your class `dealloc` (in the non-ARC case; if using ARC/strong, no release is required). – sergio Aug 11 '12 at 08:04
-2

ClassName.h

@property (nonatomic, strong) UIViewController *myView1;

ClassName.m

@synthersize myView1;

// in -(void)viewDidLoad

self.myView1 = [[Result1 alloc] init];
[self.view addSubview:self.myView1.view];
  • 5
    Please explain your answer in words, not only code, so that everyone can understand. Also, since you are answering an old question, how does your answer differ from the other answers? – Olle Sjögren Nov 21 '12 at 23:06