Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6126699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:24:31+00:00 2026-05-23T16:24:31+00:00

my question depends on my other question NSMutableArray vs NSArray i have created a

  • 0

my question depends on my other question

NSMutableArray vs NSArray

i have created a navigationController and load a TableView inside with data from the other question. Now a get a detailview and get new data from xml, so i copy my methods and modifide them.

but it is the same stucture, i does not change a lot.

But now i get the same error.

i have in detailview.h

 NSMutableArray *seminareArray;

and

@property (nonatomic, retain) NSMutableArray *seminareArray;

in detailview.m

@synthesize SeminareListeTabelle, selectedSeminar, seminareArray, receivedData;

i add this code

seminareArray = [[NSMutableArray alloc] init];
self.seminareArray = [NSMutableArray arrayWithCapacity:10];

before i add the data. and i get the error here

cell.textLabel.text = [seminareArray objectAtIndex:row];

EXC_BAD_ACCESS again some type problem

i add data to array like this

if([elementName isEqualToString:@"seminar"])   
    {
        //NSLog(@"%@", [attributeDict objectForKey:@"name"]);
        NSString *seminarName = [NSString stringWithFormat:@"%@", [attributeDict objectForKey:@"name"]];
        [seminareArray addObject:seminarName];
        [seminarName release];
    }

the array is filled with data, but after tableView reload, i get this error.

//
//  SeminareListingView.m
//  Seminar App2
//
//  Created by Alexander Frischbutter on 05.07.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "SeminareListingView.h"
//#import "SeminareView.h"

@implementation SeminareListingView
@synthesize SeminareListeTabelle, selectedSeminar, seminareArray, receivedData;

- (void) parseData:(NSString *)url   
{
    if(receivedData)   
    {
        receivedData = nil;
    }

    NSLog(@"Parsing... url: %@", url);

    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", url]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    if(theConnection)
    {
        receivedData = [[NSMutableData data] retain];
    }
    else
    {
        //label.text = @"XML nicht geladen";
        NSLog(@"XML nicht gefunden");
    }
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];

    SeminareListeTabelle = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
    SeminareListeTabelle.delegate = self;
    SeminareListeTabelle.dataSource = self;
    SeminareListeTabelle.autoresizesSubviews = YES;

    seminareArray = [[NSMutableArray alloc] init];
    self.seminareArray = [NSMutableArray arrayWithCapacity:10];

    [self parseData:[NSString stringWithFormat:@"http://akademie.kunden.fincha.com/semapp/sem_kat_arbtechnik.xml", selectedSeminar]];

    self.navigationItem.title = [NSString stringWithFormat:@"%@", selectedSeminar];
    self.view = SeminareListeTabelle;

    // Do any additional setup after loading the view from its nib.
}


- (void)startParsingData    
{
    NSLog(@"Parsing started");

    NSXMLParser *dataParser = [[NSXMLParser alloc] initWithData:receivedData];
    dataParser.delegate = self;

    [dataParser parse];
    [dataParser release];
    [receivedData release];

    NSLog(@"Received Data in seminareArray");
    /*
    for(int i = 0; i < [seminareArray count]; i++)
    {
        NSLog(@"%d is %@", i, [seminareArray objectAtIndex:i]);
        //NSLog(@"Count %d", [kategorienArray count]);
    }
    */
    //[seminareArray release];
    NSLog(@"Reload data in TableView");
    [self.SeminareListeTabelle reloadData];    
    NSLog(@"Data reloaded");    
}

- (void)viewDidUnload
{
    //[seminareArray release];
    //[SeminareListeTabelle release];

    NSLog(@"Vew unloaded");

    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

    if (cell == nil) { cell = [[[UITableViewCell alloc]
                                initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease];
    }

    if([seminareArray count] != 0)
    { 
        NSLog(@"Adding data to cell");

        NSUInteger row = [indexPath row]; 
        //cell.textLabel.text = [NSString stringWithFormat:@"bla, %d", row]; //[seminareArray objectAtIndex:row];
        cell.textLabel.text = [seminareArray objectAtIndex:row];

        NSLog(@"Added data to cell");
    }
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //NSLog(@"Count %d", [self.seminareArray count]);
    return [seminareArray count];
}

-(NSInteger) tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 0;
}

//Anzeige mit Seminaren öffnen bei Click auf die Zeile
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //gehe zurück zum ersten View
    //NSLog(@"Received Data in seminareArray");

    [[self navigationController] popViewControllerAnimated:YES];
}

- (void)connection:(NSURLConnection *)connection didReceiveResonse:(NSURLResponse *)response
{
    [receivedData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    if(receivedData)
    {
        [receivedData appendData:data];
    }
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    [connection release];
    [receivedData release];

    //label.text = @"Connection failed";
    NSLog(@"Verbindung fehlgeschlagen!");
    //[[self navigationController] popViewControllerAnimated:YES];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [self startParsingData];
    [connection release];
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    //NSLog(@"Parser was called. Element: %@", elementName);

    if([elementName isEqualToString:@"seminar"])   
    {
        //NSLog(@"%@", [attributeDict objectForKey:@"name"]);
        NSString *seminarName = [NSString stringWithFormat:@"%@", [attributeDict objectForKey:@"name"]];
        [seminareArray addObject:seminarName];
        [seminarName release];
    }
}

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
    NSLog(@"Parse Error %@", parseError);
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:24:31+00:00Added an answer on May 23, 2026 at 4:24 pm

    The problem stems from this code:

    seminareArray = [[NSMutableArray alloc] init]; // owned
    seminareArray = [NSMutableArray arrayWithCapacity:10]; // autoreleased
    

    You’re first initializing the semiareArray as an owned object, but then are re-setting it as an autoreleased object.

    Meaning, it will be released after the run-loop terminates.
    Remove the second (autoreleased) statement but keep the first, and everything should work fine.

    The reason why you’re getting the EXC_BAD_ACCESS error is because the seminareArray object is released at some point before it being used again.

    Additionally, try to debug your

    cell.textLabel.text = [seminareArray objectAtIndex:row];
    

    Try setting it as id var = [seminareArray objectAtIndex:row]; and then setting cell.textLabel.text = var; This will tell you if the error occurs due to array being dealloc’d too early, or improper cell/textLabel.


    Updated:

    There’s an additional problem is with the code:

    NSString *seminarName = [NSString stringWithFormat:@"%@", [attributeDict objectForKey:@"name"]];
    [seminareArray addObject:seminarName];
    [seminarName release]; // <--
    

    You’re creating an auto-released object seminarName, which technically has retain count 0. You’re adding it to the semiareArray, which ups the object retain count to 1. Then you’re releasing it again. Which causes it to be dealloc’d at runtime. The problem is that when you’re assigning the value to the textLabel, the object no longer exists.

    Solution: remove the [seminarName release]; Don’t worry about releasing the seminarName, since it’s auto-released, it will be released when the array is dealloc’d, or when the object it removed from the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a general question that is rather open-ended (i.e. depends on platform, application
I have two libraries, one of which depends on the other. The first library
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
Question Is there a way to have a method that will always run anytime
I have the following get method: public List<PersonalMessage> getMessagesList() { List<PersonalMessage> newList = new
This might be a silly question, but: Suppose an expression depends only on literals,
After reading this question I started to wonder: is it possible to have a
I have general question regarding the use of pointers vs. references in this particular
I know this is probably the canonical It depends... question but I'd appreciate any
I have some code which collects points (consed integers) from a loop which looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.