I make one custom cell class like this.
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWith
As mentioned by @Rajneesh071, UI changes must be performed on the main thread.
This can be done using:
[self performSelectorOnMainThread:@selector(doYourUIChanges:) withObject:nil waitUntilDone:YES];
Or if you want a section of in-line code to be performed on the main thread, use this:
dispatch_async(dispatch_get_main_queue(), ^{
/* YOUR UI STUFF */
});
This is because you are doing some UI changes on background thread. In ios you can not perform any UI changes on background thread , this will crash your app.
So you have to do your UI changes on main thread
[self performSelectorOnMainThread:@selector(doYourUIChanges:) withObject:nil waitUntilDone:YES];
Or
dispatch_async(dispatch_get_main_queue(), ^{
//Your Task
});
or
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// background code
});