Question

getting a "Thread 1: EXC_BAD_ACCES(code=2, adress=0xbf7fffffc)" error at

NSArray *tempArray ] [lijstString componentsSeperatedByString:@","];

What can i do about this?

This is the whole codepart:

-(NSMutableArray *)lijstArray{
NSString *lijstString = self.details[@"lijst"];
NSArray  *tempArray   = [lijstString componentsSeparatedByString:@", "];

self.lijstArray = [NSMutableArray array];
for (NSString *lijstValue in tempArray) {
    [self.lijstArray addObject:[lijstValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
    return self.lijstArray;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 2;
    }
Was it helpful?

Solution 2

try this:

-(NSMutableArray *)lijstArray{
    if(!_lijstArray){ //If you need get new lijstArray always, comment this line, and below "}"
        NSString *lijstString = self.details[@"lijst"];
        NSArray  *tempArray   = [lijstString componentsSeparatedByString:@", "];
        _lijstArray = [NSMutableArray array];
        for (NSString *lijstValue in tempArray) {
             [_lijstArray addObject:[lijstValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
        }
    }
    return _lijstArray;
}

OTHER TIPS

Your lijstArray getter function is infinitely recursive. Assuming lijstArray is an @property, every time you use self.lijstArray you are calling the instance method lijstArray if used as a getter or setLijstArray if used as a setter.

You are using self.lijstArray three times. The first use on the left part of the assignment operator is only calling [self setLijstArray: ... ] so while that will trample the _lijstArray iVar, it will not cause recursion.

You cause recursion in two places, though once is enough. First is with [self.lijstArray addObject: ... ] which is the same as [[self lijstArray] addObject: ... ]. This causes infinite recursion.

And then with return self.lijstArray which is the same as return [self lijstArray] -- again the lijstArray instance method is calling itself. This also causes infinite recursion.

Incidentally the stack trace would be informative-- you'd have a very deep stack.

Check to make sure the line:

self.details[@"list"]; 

Is not null. Also check to make sure tempArray and lijstString are being allocated and initialized.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top