Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3277612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:23:19+00:00 2026-05-17T19:23:19+00:00

I am currently working in small chat app in iPhone. I am call to

  • 0

I am currently working in small chat app in iPhone. I am call to web services; one for data sending, and other for get friends response. I am implementing the code as follows:

NSMutableData *webData;
 NSXMLParser *xmlParser;
 NSMutableString *xmlParsingResult;
 NStimer *timer;
-(IBAction)send:(id)sender
{
 //req include web request info
 NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
  if (conn) 
  {
   webData = [[NSMutableData data] retain];
  }
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
 [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
 [webData appendData:data]; 
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
 [connection release];
 [webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
 xmlParser = [[NSXMLParser alloc] initWithData: webData];
 [xmlParser setDelegate: self];
 [xmlParser setShouldResolveExternalEntities: YES];
 [xmlParser parse]; 
 [xmlParser release];
 [connection release];
 [webData release];
}

-(void)parser:(NSXMLParser *)xmlparser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName   attributes: (NSDictionary *)attributeDict
{
 if( [elementName isEqualToString:@"string"])
 {
  if(!xmlParsingResult)
  {
   xmlParsingResult = [[NSMutableString alloc] init] ;
  }  
 } 
}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
 [xmlParsingResult appendString: string]; 
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
 if( [elementName isEqualToString:@"string"])
 {
  if(timer!=nil)
  {    
  }
  else
  {
 [self performSelectorInBackground:@selector(CallResponse) withObject:nil];
  }
  xmlParsingResult=nil;
  [xmlParsingResult release];
 } 
} 
//==================================================================================================================
-(void)CallResponse
{
 NSLog(@"timer start:");
 NSAutoreleasePool *timerNSPool = [[NSAutoreleasePool alloc] init];
 timer = [NSTimer scheduledTimerWithTimeInterval:10.0  target:self selector:@selector(Refresh:) userInfo:nil repeats: YES]; 
 NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
 [runLoop run];
 [timerNSPool release];
}
-(void)Refresh:(NSTimer *)TimeVal
{
// call web service to get response 
// if error occur then timer will be release and nil
}

My app crashes and it throws the following error:

bool _WebTryThreadLock(bool), 0x7089e20: 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...

How can I debug why this happens?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:23:19+00:00Added an answer on May 17, 2026 at 7:23 pm

    THe error message tells you exactly what the problem is. For what it’s worth, there’s no need to create a background thread and run loop just to start an NSTimer. You may as well just create the NSTimer in your main thread—it won’t block it, it’ll just sit in the run loop and fire when it needs to. There’s no need for -performSelectorInBackground:withObject:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m currently working on a small web app that allows people to search for
I am currently working on a small app engine project with python, jquery. I
I'm currently working on a small iPhone game, and am porting the 3d engine
I'm currently working on a small project: there's a protocol for sending some strings
I'm currently working with the MKMapView and I'm trying to get data to appear
I am currently working on a small app where users accrue points by completing
I am currently working on a small project using RESTlet on Google App Engine/Java.
I'm currently working at a small web development company, we mostly do campaign sites
I'm currently working on a small web application using Visual Studio 2008 Express. I'm
I'm currently working on a small webapp where I work. I've created this for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.