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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:52:02+00:00 2026-05-17T00:52:02+00:00

everyone I got problem here I need to update a plist data in a

  • 0

everyone I got problem here

I need to update a plist data in a period time

and I use Tab Bar to switch 2 views

When I select to view1 ,It will load data from an URL

But if I switch to view2 , the view1 still update the data

If you switch to view2 and switch back ,view2 keep updating the data.

and this is the code I’m using to update the data
in LoadData.h

@interface LoadData : UITableViewController < NSNetServiceBrowserDelegate > {
NSArray     *plist;
NSTimer     *timer;
}

in LoadData.m

static const float REFRESH_STATUS_TIME = 2.0;
- (void)viewDidLoad {
timer = [NSTimer scheduledTimerWithTimeInterval:REFRESH_STATUS_TIME
                                                    target:self
                                                    selector:@selector(timerFired:)
                                                    userInfo:nil                
                                                    repeats:YES];
[super viewDidLoad];
}
- (void)timerFired:(NSTimer *)theTimer{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://10.85.28.99/envotouch/req_light.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
                                          timeoutInterval:60.0];

    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    NSLog(@"\n\nCONNECTION:   %@", theConnection);
    NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil]; 
    NSString *listFile = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];   
    self.plist = [listFile propertyList];

    [self.tableView reloadData]
}

So my question is how to terminated the data update when I switch to another view ?

thanks for the reply…..this a big bug annoying me

  • 1 1 Answer
  • 4 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-17T00:52:02+00:00Added an answer on May 17, 2026 at 12:52 am

    If you use the asynchronous NSURLConnection you can send the cancel message to the connection (that is still busy loading) when you switch to another view. The asynchronous method will keep your UI responsive as a bonus, which the synchronous method does not as Ole Begemann pointed out.

    You can find information on how to use the asynchronous method here: URL Loading System Programming Guide

    Edit: You should presumably also stop the timer (by sending it an invalidate message) when the view is not shown, this way the timer does not fire when the view is not shown causing the load of data.

    NSTimer Class Reference

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

Sidebar

Related Questions

everyone, I got a strange problem, please help. the error message is: Run-time error
Hey everyone I got a javascript problem I can't seem to find a specific
Hey everyone, great community you got here. I'm an Electrical Engineer doing some programming
UPDATE & SOLUTION : Everyone, for whoever has this problem in the future, I
Update : I edited the code, but the problem persists... Hi everyone, this is
So here I got this little program which everyone obviously understands. include <iostream> include
everyone,I am new to PP but got stuck in a problem when importing NumPy
hey everyone... so i'm working on a database design class for university. I've got
everyone! I have sprite moving by action, what have health bar (progress bar). When
I've got some problem with my function and don't know how to solve this

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.