ios - Getting '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object' while trying to reorder cells in UITableView -
i'm using afnetworking
fetch json
data in uitableview
cells. have declared array nsmutablearray
, still i'm getting -[__nscfarray removeobjectatindex:]: mutating method sent immutable object
error , application crashing whenever i'm trying reorder cells.
here's logic i'm using reordering -
-(void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { nsstring *item = [self.jobsarrayfromafnetworking objectatindex:fromindexpath.row]; [self.jobsarrayfromafnetworking removeobject:item]; [self.jobsarrayfromafnetworking insertobject:item atindex:toindexpath.row]; }
i tried solutions being answered before, couldn't understand. can tell me what's going wrong here? thanks!
your @property jobsarrayfromafnetworking
either initialized nsarray
or declared copy
.
both lead error message since backing ivar point (immutable) nsarray
.
if declared property of nsmutablearray
type, use strong
storage modifier instead of copy
.
Comments
Post a Comment