开发者

NULL elements in NSMutableArray

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 objectAtInd开发者_C百科ex: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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜