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 657019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:46:39+00:00 2026-05-13T22:46:39+00:00

I’m writing code to check if there is a network connection present. In a

  • 0

I’m writing code to check if there is a network connection present. In a nutshell, the order of events that I want to occur goes like this:

  1. User requests information from a web service.
  2. A timer starts, and checks every second if a connection exists. If it doesn’t, put up a view.
  3. When the information is all received from the web service, the timer in 2 ends.

From what I understand, having the timer run while having the web service load requires a new thread with the timer on it. I understand how to do that and am fine. From what I understand, to end that thread, I call [thread cancel];. How do I take care of memory management from within that thread. There was a timer in there, among other things.

My other thread self terminates, and when it does it releases all it’s contents. Is there a way to do that with cancel? Thanks.

  • 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-13T22:46:39+00:00Added an answer on May 13, 2026 at 10:46 pm

    You will need to keep anything using UIKit in the main thread since UIKit components are not guaranteed to be thread safe. So, your timer and alert are in your main thread, your network traffic is in the background thread. The background thread is going to communicate with the main thread using one of the performSelectorOnMainThread: variants. You can certainly use a timer in a background thread as long as it communicates with your UI via a similar function and does not try to do the alert itself. In terms of communicating from the main thread to your background threads take a look at the performSelector:onThread methods.

    In terms of memory you will create a new autorelease pool in the entry point of the new thread and you will drain that pool at the end of the thread. Within the thread itself you manage memory exactly as you do in a main thread, and when the thread terminates all of its memory is released.

    For all the details check out the NSThread docs. Here is Apple’s memory management document with notes on Autorelease pools

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and

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.