Lefora Free Forum
login join
Loading
619 views

iPhone program crashes when linking second screen to screen initially loaded from link in table row

Page 1
1–2
rookie - member
1 posts

Hi everyone,

  I'm having a problem with my iPhone application that I've been fighting with for around 12 hours now (otherwise I wouldn't be a bother with what is probably a simple question with a simple answer).  I've created a program that uses both a navigation bar and a tab bar, and both run perfectly.  The main windows linked to each tab-bar button are table views, and each row of each table links to another table.  Each row in the second table then links to a screen on which data or buttons is displayed.  Now, on one of these screens is a button that switches the display to a similar screen (but one with its own view controller) after the display of an action sheet.  All of this worked perfectly until I tried to create a button in the second window that links back to the original window - clicking the button causes the program to crash.  In debugging, I eliminated all code in the new button's code and placed an NSLog there and a breakpoint directly before, but the program still crashed.  Simply calling a method from the new button causes the program to crash.  I have absolutely no idea why this happens, but I suspect it has something to do with the way the second screen is called.

To help visualize the structure that leads up to this second screen, it goes:

tab bar-button --> table view --> table view --> first regular screen --> second regular screen

Here's the code that opens the second regular screen from the first regular screen:

-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        LucidDreamAlarmRecording *lucidDreamAlarmRecording = [[LucidDreamAlarmRecording alloc]             initWithNibName:@"LucidDreamAlarmRecording" bundle:nil];
        [self.view insertSubview:lucidDreamAlarmRecording.view atIndex:4];
        [lucidDreamAlarmRecording release];
    }
}

The index of the first regular screen is 3 - I know because I attempted to put the second screen into index 3 initially, and it displayed the second regular screen under the button that generates the action sheet that opens the second window.  Changing atIndex to 5 makes no difference - it shows the same thing as atIndex:4, and crashes the same way.

I would really appreciate it if anyone could help me solve this problem.  I'm uncertain whether I posted enough information and code, so if it isn't enough, I can post whatever else is needed to help.

All the best,
Andrew

?
288 posts

Are you certain that you [LDAR alloc]init] code is setting up an object correctly?  And you're releasing that object almost immediately.  Are you certain that insertSubview is retains that object?  Comment off the release and I suspect, you'll be happier.

__________________
Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!