0
- (void)viewDidLoad {

    webCollectionOnScroller=[[NSMutableArray alloc] init];
    scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
    scroll.pagingEnabled = YES;
    currentWeb=0;
    globali=0;
    firstTime=0;
    [loadingWeb startAnimating];
    alertForLoading = [[UIAlertView alloc] initWithTitle:@"Loading..." message:@"link is being loaded.\n Please wait!" delegate:self cancelButtonTitle:@"Back" otherButtonTitles:nil];
    [alertForLoading show];
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    // Adjust the indicator so it is up a few pixels from the bottom of the alert
    indicator.center = CGPointMake(alertForLoading.bounds.size.width / 2, alertForLoading.bounds.size.height - 100);
    [indicator startAnimating];
    [alertForLoading addSubview:indicator];
    [NSThread detachNewThreadSelector:@selector(initializeParser)toTarget:self withObject:nil];
    [super viewDidLoad];
}

and this is the console error "-[linksGallery respondsToSelector:]: message sent to deallocated instance 0x639a890 [Switching to process 2211] "

It doesn't crash when I comment release statement on main view

-(IBAction) goToLinks{
    linksGallery *showLinks=[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil];
    [self.navigationController pushViewController:showLinks animated:YES];
        //[showLinks release];
}
Idrees Ashraf
  • 1,363
  • 21
  • 38
  • More info please! I which line does it crash? What is `linksGallery`? – dasdom May 23 '12 at 11:57
  • change this line and check --> indicator.center = CGPointMake(100, 200); may be you are loosing reference to alertForLoading. If it doesn't work comment NSThread line and check. I hope something is gng wrong in initializeParser method. – Dee May 23 '12 at 11:57
  • 1
    That crash is not due to a "memory leak", it's due to just the opposite -- an object that got deleted too soon. – Hot Licks May 23 '12 at 11:58
  • Are you using ARC? Check whether there is a weak property which should be strong. – dasdom May 23 '12 at 12:02
  • Note that you should have been provided with a very instructive exception traceback ([though, alas, Xcode 4 goes out of its way to hide it](http://stackoverflow.com/q/8100054/581994)). This will at least tell you where the exception occurred. – Hot Licks May 23 '12 at 12:03
  • 1
    Class names should start with an upper-case character. – Hot Licks May 23 '12 at 12:04

4 Answers4

1

Try with putting the below line at first:

[super viewDidLoad];

inside the "dealloc()" function:

[super dealloc];

at the end of all releases.

Hope this will help you.

Nishant B
  • 2,897
  • 1
  • 18
  • 25
0

That error message means the instance of linksGallery has been released by the time you send it the message 'respondsToSelector'. To debug this try also setting it to null when you release it, then it won't crash, although it probably won't do what you want either.

Mark
  • 6,108
  • 3
  • 34
  • 49
0

Try out following codes

-(IBAction) goToLinks{
    linksGallery *showLinks=[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil];
    [self.navigationController pushViewController:[showLinks mutableCopy] animated:YES];
    [showLinks release];
}

or

-(IBAction) goToLinks{
    linksGallery *showLinks=[[[linksGallery alloc] initWithNibName:@"linksGallery" bundle:nil] autorelease];
    [self.navigationController pushViewController:showLinks animated:YES];
    //[showLinks release];
}

Hope this will help

Mitul Nakum
  • 5,514
  • 5
  • 35
  • 41
0

Make your ViewDidLoad look like this :

- (void)viewDidLoad {

[super viewDidLoad];

webCollectionOnScroller=[[NSMutableArray alloc] init];
scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 370, 320, 94)];
scroll.pagingEnabled = YES;
currentWeb=0;
globali=0;
firstTime=0;
[loadingWeb startAnimating];
alertForLoading = [[UIAlertView alloc] initWithTitle:@"Loading..." message:@"link is being loaded.\n Please wait!" delegate:self cancelButtonTitle:@"Back" otherButtonTitles:nil];
[alertForLoading show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(alertForLoading.bounds.size.width / 2, alertForLoading.bounds.size.height - 100);
[indicator startAnimating];
[alertForLoading addSubview:indicator];
[NSThread detachNewThreadSelector:@selector(initializeParser)toTarget:self withObject:nil];

}
Jake
  • 3,973
  • 24
  • 36
Mutawe
  • 6,464
  • 3
  • 47
  • 90