views:

53

answers:

1

Hi, for some reason this tableview keeps crashing and it seems like the tableview is unable to display the secondsString for some reason but i have no idea why... please help me out here cause i have no idea what i could be doing wrong..... Thanks!!

#import "SettingsView.h"

@implementation SettingsView

- (void)viewWillAppear:(BOOL)animated {

   [super viewWillAppear:animated];
   transmissionSetup = [[TransmissionSetupViewController alloc]     initWithNibName:@"TransmissionSetupViewController" bundle:nil];
   transmissionSetup.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
   NSLog(@"%i", [self getMinutes]);
   [self setSeconds:10];
   secondsString = [NSString stringWithFormat:@"%i", [self getSeconds]]; 
   [self.tableView reloadData];
}

 #pragma mark Table view methods

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

   static NSString *CellIdentifier = @"Cell";

   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
    }

   if (indexPath.section == 0) {
       cell.textLabel.text =  @"Every:";
       cell.detailTextLabel.text = secondsString;
    }
    // Set up the cell...

    return cell;
}

@end
+1  A: 

You initialize your secondString with autoreleased string - so it is not guaranteed that it will be valid outside current scope. You need to retain it upon initialization (and don't forget to release later)

I would advise you to have a look at objective-c properties for accessing ivars.

Vladimir
i intialized it in my header file like this: NSString *secondsSTring;how do i retain it upon intialization?
Christoph v
alright i got it thank you very much!!!
Christoph v