iphone - EXC_BAD_ACCESS while adding data to array, using 2 NSOperations simultaneously -


i have:

1) starting 2 asynchron nsurlrequests simultaneously

2) 1 of 2 requests has loaded xml data, nsoperationqueue used start xml parser. hereby, parseoperations work excatly in apple's lazytableimages example.

inforequesthelper.m

// ...  case getblogentries: {     blogparseoperation *parser = [[blogparseoperation alloc] initwithxmlstring:result delegate:self];     parser.tag = helper.requesttag;      [queue addoperation:parser]; // start "parseoperation"      [parser release];      break; } case gettweets: {     twitterparseoperation *parser = [[twitterparseoperation alloc] initwithxmlstring:result delegate:self];     parser.tag = helper.requesttag;      [queue addoperation:parser]; // start "parseoperation"      [parser release];      break; }  // ... 

3) when parsing finished parser:didfinishparsing: fires.

inforequesthelper.m

- (void)parser:(parseoperationbase *)parser didfinishparsing:(nsarray *)entries {     // save data, remove completed request list     [self.requestsinprogress removeobjectforkey:parser.tag];     [self.resultobjects addobjectsfromarray:entries];  // <= !!! exc_bad_access !!! here      // ..     } 

the problem: when first event arrives here, objects can added array. when second arrives, there exc_bad_access.

edit: think trying access resultobjects variable in both parsing methods. , resultobjects mutablearray. problem when trying add or remove object variable 1 function function trying access it. give error. have learned when creating multi-threaded app.

you can see apple documentation on thread unsafe classes. , best way avoid use nsarray object instead.

and when want add or remove object variable can first put contents mutable array , manipulation on , assign original object.

i hope makes sense. know how hard have been find such errors.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -