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

The Archive Base Latest Questions

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

I would like to know how to get local notifications while my application’s NSTimer

  • 0

I would like to know how to get local notifications while my application’s NSTimer is firing in the background. My NSTimer checks a particular folder for files every second for 10 minutes in the background. How would I go about receiving a local notification if a file is found?

EDIT : Code :

- (void) createTimeThread: (float) pIntervalTime
{
    [NSThread detachNewThreadSelector:@selector(startTimerThread) 
                             toTarget:self withObject:nil];
}

- (void) startTimerThread
{
    UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication]
                                         beginBackgroundTaskWithExpirationHandler:^{}];

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    NSRunLoop* runLoop = [NSRunLoop currentRunLoop];

    myTimer = [NSTimer scheduledTimerWithTimeInterval:1
                                               target:self
                                             selector:@selector(conditionChecking:)
                                             userInfo:nil
                                              repeats:YES]; 

     [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
     [pool release];

    [[UIApplication sharedApplication] endBackgroundTask:bgTask];
}

- (void)conditionChecking:(NSIndexPath *)indexPath
{
    NSString *pathForFile = @"/User/Library/Logs/CrashReporter"; 

    NSFileManager *fileManager = [NSFileManager defaultManager];

    if ([fileManager fileExistsAtPath:pathForFile]) { // Directory exists
        NSArray *listOfFiles = [fileManager contentsOfDirectoryAtPath:pathForFile error:nil];

        if (!listOfFiles || !listOfFiles.count)
        {
            NSLog(@"No Core Dumps found....."); 
        }
        else
        {
            NSLog(@"Core Dump(s) found! :%@", listOfFiles);
        }
    }
}
  • 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-25T11:39:14+00:00Added an answer on May 25, 2026 at 11:39 am

    I believe that you want to notify all other classes that folder is filled with files.

    Following steps can do that for you.

    1. write following line in initialization of class where you want to receive notification.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkFiles:) name:@"FILES_AVAILABLE" object:nil];

    1. Write methods checkFiles with following signature in same class.

      -(void)checkFiles:(id)sender

    2. Add following line in timer class when files are available.

      [[NSNotificationCenter defaultCenter] postNotificationName:@"FILES_AVAILABLE" object:self];

    If this is not helpful then you can use NSUserDefault to store status of application(Files are available or not in you case). OR With if you are interested in design patterns read about Observer Pattern.

    In case you want to post notification when your application is in background mode and some process that is still running gets some update then that can be achieved using notification queue. read following link. I am not writing code because code is given in link itself.

    http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Articles/NotificationQueues.html#//apple_ref/doc/uid/20000217-CJBCECJC

    Post here if you need more help.

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

Sidebar

Related Questions

Anyone know what a virgin /usr/local folder would look like on a brand new
I would like to know how to get the name of the property that
I would like to know what events get executed (if any) after a user
With the XML below, I would like to know how to get the value
I'm using SQL Server 2005 and would like to know how I can get
I'm facing a simple problem I would like to get a local path from
I would like my application to send/receive requests from a LOCAL server, my laptop
I would like to know how to parse XML file from local in Titanium
i would like know some reference. I know i can googling it. but prefer
Would like to know what a programmer should know to become a good at

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.