Access problem with NSMutableArray

Posted by pbcoder on Stack Overflow See other posts from Stack Overflow or by pbcoder
Published on 2010-06-02T18:32:36Z Indexed on 2010/06/02 18:34 UTC
Read the original article Hit count: 146

Hi, my problem is that I can't access my NSMutableArray in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}.

I create my NSMutableArray here:

nodes = [xmlDoc nodesForXPath:@"/xml/items/item/short_desc" error:nil];

if (nodes != nil && [nodes count] >= 1) {
    for (int i = 0; i < [nodes count]; i++) {
        CXMLElement *resultElement = [nodes objectAtIndex:i];
        result = [[[[resultElement attributeForName:@"data"] stringValue] copy] autorelease];       
        [short_desc addObject:result];
    }
}

and I can print out the content of short_desc everywhere with:

NSLog([short_desc objectAtIndex:0]);

but not in:

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

.....

NSString *date = [name objectAtIndex:0];


labelDate.text = date;
.....   

return cell;}

if I use:

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

.....

NSString *date = @"text...";


labelDate.text = date;
.....   

return cell;}

it works correctly.

ANY SOLUTION FOR THIS PROBLEM???

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c