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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:10:54+00:00 2026-05-25T13:10:54+00:00

I’m trying to display an image from a webcam in my app using HJCache

  • 0

I’m trying to display an image from a webcam in my app using HJCache.
The webcam refreshes its image every 5 minutes.
I’d like to have a refresh button, so that users could click it to see a new image (if available).
My code so far:

-(void)viewDidLoad {
    // init HJObjManager
    objMan = [[HJObjManager alloc] initWithLoadingBufferSize:6 memCacheSize:20];
    // refresh button
    UIBarButtonItem *buttonRefresh = [[UIBarButtonItem alloc]
                     initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                     target:self
                     action:@selector(refreshPhoto:)];
    self.navigationItem.rightBarButtonItem = buttonRefresh;
    [buttonRefresh release];
    NSURL *url =  [NSURL URLWithString: @"http://webcamurl"];
    img1.url = url;
    [self.objMan manage:img1];
}

-(IBAction) refreshPhoto: (id) sender {
    // ?
}

Could you give me an hint on how to implement refreshPhoto?

Edit: ender pointed me to emptyCache. If I understand it ok, it should be used by HJMOFileCache, so my code now is:

-(void)viewDidLoad {
    NSString *documentsDirectory;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    documentsDirectory = [paths objectAtIndex:0];
    documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"imageCache/"];
    objMan = [[HJObjManager alloc] initWithLoadingBufferSize:6 memCacheSize:20];
    HJMOFileCache* fileCache = [[[HJMOFileCache alloc] initWithRootPath:documentsDirectory] autorelease];
    fileCache.fileCountLimit = 100;
    fileCache.fileAgeLimit = 300; // 5 min
    objMan.fileCache = fileCache;
    // refresh button 
    UIBarButtonItem *buttonRefresh = [[UIBarButtonItem alloc]
                     initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                     target:self
                     action:@selector(refreshPhoto:)];
    self.navigationItem.rightBarButtonItem = buttonRefresh;
    [buttonRefresh release];
    NSURL *url =  [NSURL URLWithString: @"http://webcamurl"];
    img1.url = url;
    [self.objMan manage:img1];
    [super viewDidLoad];
}

-(IBAction) refreshPhoto: (id) sender {
    [self.objMan.fileCache emptyCache];
    [self.objMan manage:img1];
}

It doesn’t work though, when I click the refresh button nothing happens, the image does not refresh.
Any idea?

Edit: ender suggested that maybe the cache files do not get deleted by emptyCache (if I understand it right), but it looks like they actually do.
From NSLog before and after the emptyCache:

2011-09-09 16:57:33.842 Ready dir before emptyCache: (
    "http:__www.meteogallipoli.it_cam_cam1.jpg"
)
2011-09-09 16:57:33.845 Loading dir before emptyCache: (
)
2011-09-09 16:57:33.856 Ready dir after emptyCache: (
)
2011-09-09 16:57:33.859 Loading dir after emptyCache: (
)

“Ready” and “Loading” are the directories where objMan stores files already downloaded and being downloaded, respectively.
Maybe the problem is in making objMan manage the image again?

  • 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-25T13:10:55+00:00Added an answer on May 25, 2026 at 1:10 pm

    I think its because you configured the object manager with both a file cache and a memory cache. When you empty the file cache, there are still images in the memory cache? Try instanciating the object manager with

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to render a haml file in a javascript response like so:
I am trying to loop through a bunch of documents I have to put

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.