iphone - NSMutableArray can't be added to -


I had a similar problem before, and it did not get a satisfactory answer.

I have a visual controller with a property called "County" which is an NSMutableArray. I am going to drill a scene on a navigation screen which is about choosing counties for a geographic search. The search page goes down on the "selection counties" page.

I pass the other controller to NSMutableArray * counties because I suppress another on the navigation stack. I actually set the "selected types of property" (one NSmutable array) of an other controller in the "counties" of my second controller with an indicator, as you will see below

When I AddObject , I get this:

  End the application due to non-exception 'NSInternalInconsistencyException', Reason: '*** - [NSCFArray insertObject: AtIndex:]: The change method sent to an irreversible item ' 

here Security code:

In SearchViewController.h:

  @interface SearchViewController: UIViewController {.... NSMutableArray * counties; } .... @ property (nontomic, raten) nsmutbearare * counties;  

In SearchViewController.m:

  - (zero) getLocationsView {[keywordField resignFirstResponder]; SearchLocationsViewController * locationsController = [[Search Visual Controller alloc] initWithNibName: @ "SearchLocationsView" bundle: zero]; [Self. Navigation controller Push ViewController: Places Controller Animated: Yes]; [Places controller set selected selected: self [Places controller release]; }  

SearchLocationsViewController.h:

@interface eventmodification view view controller: UIViewController & lt; UITableViewDelegate, UITableViewDataSource & gt; {... NSMutableArray * selected mount; } ... @property (nontomic, rETAIN) NSMutableArray * selected content;

In SearchLocationsViewController.m (here, we are activating each element in a table or not in the list of selected counties):

  - (Zero) Table view: (UITableView *) Table view was selected SelectandApath: (NSIndexPath *) Index path {UITableViewCell * cell = [tableView cellForRowAtIndexPath: indexPath]; If ([the self-selected countries include: [self. Data object atxx: indexpath.ro]]) // {we are doing / destructing! [Self. Removed items from selected countries: [self Data ObjectAut Index: IndexPath.ro]]; Cell.accessoryView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "red_check_inactive.png"]]; } Other {[Himself Add selected countries to object: [self. Data object atindex: indexpath.ro]]; Cell.accessoryView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "red_check_active.png"]]; } [Select Table View: Rooted Approximate: IndexPath Animated: Yes];  

We die on . [Self. Select Available Ad Objects .... there.

Now, when I myself myself Selected square class] , it tells me that it is an NSCFRERE

How does this happen? I understand the class bundles (or I think I do it anyway), but it's clearly a specific type, and it's somehow losing subclassing, which kills everything, I I do not understand why this happens.

My guess is that you are not allocating the array properly (e.g., NSMutableArray * Arr = [[NSArray alloc] init] , or NSArray in the NSMutableArray variable. You post the code where you start the array Are you?


Comments