I have following error msg in console when using NSThread "Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now..."
I have submit my sample code here
- (void)viewDidLoad {
appDeleg = (NewAshley_MedisonAppDelegate *)[[UIApplication sharedApplication] delegate];
[[self tblView1] setRowHeight:80.0];
[super viewDidLoad];
self.title = @"Under Ground";
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[NSThread detachNewThreadSelector:@selector(CallParser) toTarget:self withObject:nil];
}
-(void)CallParser {
Parsing *parsing = [[Parsing alloc] init];
[parsing DownloadAndParseUnderground];
[parsing release];
[self Update_View];
//[myIndicator stopAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
here "DownloadAndParseUnderground" is the method of downloding data from the rss feed and
-(void) Update_View{
[self.tblView1 reloadData];
}
when Update_View method is called the tableView reload Data and in the cellForRowAtIndexPath create error and not display custom cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomTableviewCell *cell = (CustomTableviewCell *) [tblView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"customCell"
owner:self
options:nil];
cell = objCustCell;
objCustCell = nil;
}
The "SYSTEM THREAD EXCEPTION NOT HANDLED" is a common Windows 10 error that occurs mainly due to an outdated or incompatible driver. What makes it trickier to fix than other BSODs is that multiple drivers can cause the issue and sometimes your computer may not detect them all.
When using threads, it can cause increased complexity, and debugging your code can become much more difficult. It is possible to add logic to make sure data is synchronized across threads, but too much reliance on synchronization can lead to performance issues, which affects an application's scalability.
Thread management is handled by the thread library in user space, which is very efficient. However, if a blocking system call is made, then the entire process blocks, even if the other user threads would otherwise be able to continue.
if there is a crash, there is a backtrace. Please post it.
Method names start with lowercase letters, are camelCased, and do not contain underscores. Following these conventions will make your code easier to read by other iOS programmers and learning these conventions will make it easier to understand other iOS programmer's code.
You can't directly or indirectly invoke methods in the main thread from background threads. Your crash and your code both indicate that you are freely interacting with the main thread form non-main threads.
The documentation on the use of threads in iOS applications is quite extensive.
Your problem should come because you load your UIViewController from a thread that's not the main thread. Tipically when you try to charge data before loading the view. To arrange this you can try to do this 1. Add a method to load your viewcontroller with just one param
-(void)pushViewController:(UIViewController*)theViewController{
[self.navigationController pushViewController:theViewController animated:YES];}
2.Change your code (commented below) in your asynchronous loading to "PerformSelectorOnMainThread"
-(void)asyncLoadMyViewController
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
MyViewController *myVC = [[myVC alloc] initWithNibName:@"myVC" bundle:nil ];
[self performSelectorOnMainThread:@selector(pushViewController:) withObject:myVC waitUntilDone:YES];
// [self.navigationController pushViewController:wnVC animated:YES];
[wnVC release];
[pool release];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With