Introduction
In my current application, I have a UITableView that contains custom cell objects. Custom UIViewCellObjects are simply subclassed from the standard UITableViewCell class. Custom cells contain information about the start of background loading and update them using things like percent complete, etc.
Custom cell objects listen for NSNotifications from loading processes running in the background, and when they receive a notification, they simply update their own view controls with new information (for example, percent load).
Now that the loading process is complete, I re-order the array of active loading objects and reload the tableview as follows:
-(void) uploadFinished: (NSNotification*)notification { NSDictionary *userInfo = [notification userInfo]; NSNumber *uploadID = [userInfo valueForKey:@"uploadID"]; if (uploadID.integerValue == uploadActivity.uploadID) { [[ApplicationActivities getSharedActivities] markUploadAsFinished:uploadActivity]; [parentTable reloadData]; [self setUploadComplete]; } }
Now this method takes place in tableviewcell objects, and, as you can see, they call their own UITableView to reload data immediately after sorting the array. The markUploadAsFinished method simply reorders the array, so all ready-made downloads are placed at the top, so it will be displayed this way in a UITableView.
Problem
Now the problem is that when you call this method, sometimes the following error occurs: "NSInvalidArgumentException", reason: '- [CALayer tableView: numberOfRowsInSection:]: unrecognized selector sent to the instance
I donโt get this all the time, sometimes the whole process runs fine, and ready-made downloads appear at the beginning of the UItableview, and in other seemingly random cases this fails. I really donโt understand what is going on here.
Custom cells are loaded from a .NIB file as follows:
UploadCell *cell = [activeUploadsTable dequeueReusableCellWithIdentifier:@"UploadProgressCell"]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"UploadCellView" owner:self options:nil]; cell = customCell; }
Is there anyone who could understand what is going on here?
EDIT
First of all, I found this error to appear right in the line where: reloadData p>
called inside custom cell objects.
In addition, it seems that the instance that it sends to the methods may change. I also got this error:
'NSInvalidArgumentException', reason: '-[UIScrollViewPanGestureRecognizer tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
I really donโt know what is going on here.