Wednesday 15 June 2011

ios - Does assigning an autorelease object to a retained property increase its retain count? -


I would have thought 'self.data =' autorelease will maintain NSMutableArray objects and NSMutableDictionary objects include it but in the end I ExC_BAD_ACCESS gets when the cellForRowAtIndexPath method of the table tries to use NSDictionaries in self.data

  @property (strong, nonatomic) NSMutableArray * data; - (zero) updateReceivedData: (NSData *) jsonData {NSMutableArray * fetchedData = [NSJSONSerialization JSONObjectWithData: jsonData Option: NSJSONReadingMutableContainers Error: & amp; Error]; Self.data = [Self Convert Date: FermatedData Format: KMISXLadTime Format]; [Self.tableViewReloadData]; }} - (NSMutableArray *) convertDates: (NSMutableArray *) array withFormat: (NSString *) format {NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [DateFormatter setDateFormat: format]; NSMutableArray * newArray = [NSMutableArray arrayWithArray: array]; For (in the NSMutableDictionary * newArray for dict) {id key in dict.allKeys} {if ([[dict objectForKey: key] isKindOfClass: [NSString class]]) {NSString * value = [dict objectForKey: key]; NSDT * date = [DateFormat Date: FrameString: Value]; If (date) [dict setObject: for date key: key]; }}} [DateFormatter release]; New araes; (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath:   

{Fixed NSString * CellIdentifier = @ "cell"; Customcell * cell = [tableview decouwer reusable cell with identifier: cell identifier]; If (cell == zero) {nslog (@ "cell was zero"); Cell = [[[Custom CL Alok] Inte] AutoEques]; } NSDictionary * dict = [[NSDictionary alloc] init]; If (_isfilter) {dict = [self.filteredData objectAtIndex: indexPath.row]; } Other {dict = [self.data objectAtIndex: indexPath.row]; } NSLog (@ "Filling Label 1"); Cell.IDLabel.text = [[Dict objectForcae: @ "id"] stringwheel]; NSLog (@ "Philing Label 2"); Cell.firstNameLabel.text = [dict objectForKey: @ "First name"]; [Core release]; Return cell; }

Turn on the corpse and see that this problem captures (EXC_BAD_ACCESS means Not necessarily a more released object, but it can be).

What happens with the full value of maintaining an object.

However, strong property means that the object is retained, yes, if you assign it via setter (i.e. self.data = ... and No _data = ...).

No comments:

Post a Comment