0

I have a problem... IN my MuttableArray have N element, but all elements is null

.h
        @interface ViewController : UIViewController <UITableViewDelegate,UITableViewDataSource> {
            NSMutableArray *listProjectPost;
        }

@property (retain,nonatomic) NSMutableArray *listProjectPost;

.m
@implementation ViewController
@synthesize  listProjectPost;

-(void)dealloc
{
    [self.listProjectPost release];
    [super dealloc];
}

-(void)viewWillAppear:(BOOL)animated{
    self.listProjectPost = [NSMutableArray array];

// loop code
// current element
            currentNews *dop = [[currentNews alloc] init];
            [self.listProjectPost addObject:[dop createElement:node]];
            [dop release];
}

in

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
currentNews *dop = [self.listProjectPost objectAtIndex:indexPath.row];
cell.textLabel.text = [dop getTitle];
...
}

all ok in top view (view when creating) but next index i have error - EXC_BAD_ACCESS

sorry for my english

1
  • I poorly explained. initialization table, I rendered the 5 elements (ie CurrentNews not null) but when I start flipping the table (bottom) then vyleaet error and an array of currentNews zero (actually there and every element of 34 null, and must be a specific element) with which it may be the reason? Commented Jul 21, 2011 at 20:43

1 Answer 1

1

If you need to store a null value in an Objective-C array, use [NSNull null]. You should check [drop createElement:node] to see if it is nil before adding it to your array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.