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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:53:21+00:00 2026-06-09T16:53:21+00:00

I have a method called cache image. This uses a NSNotification centre to post

  • 0

I have a method called cache image. This uses a NSNotification centre to post the info that image has been cached. I have the data NSMutableDictionary *userInfo. I’m trying to add an observer to retrieve the image and save using the _URL as the key. The problem is both URL and image are added to the dictionary as object with their own keys. Is it possible to retrieve the image for the corresponding key?

 - (void)cacheImage:(UIImage *)image
   {
    if (!_cancelled)
    {
    if (image && _URL)
    {
        BOOL storeInCache = YES;
        if ([_URL isFileURL])
        {
            if ([[[_URL absoluteURL] path] hasPrefix:[[NSBundle mainBundle] resourcePath]])
            {
                //do not store in cache
                storeInCache = NO;
            }
        }
        if (storeInCache)
        {
            [_cache setObject:image forKey:_URL];
        }
    }
    NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                         image, AsyncImageImageKey,
                                         _URL, AsyncImageURLKey,
                                         nil];
    NSLog(@"%@",_URL);

        if (_cache)
        {
            [userInfo setObject:_cache forKey:AsyncImageCacheKey];
        }

        _loading = NO;
        [[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish
                                                            object:_target
                                                          userInfo:[[userInfo copy] autorelease]];
    }
    else
    {
        _loading = NO;
        _cancelled = NO;
    }

 }

in my other class viewcontroller.m file

   -(void)ViewDidLoad{

     [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(imageLoaded:)
                                             name:AsyncImageLoadDidFinish
                                           object:nil];
    }


     - (void)imageLoaded:(NSNotification *)notification
  {

    NSMutableDictionary *imageCache = notification.object;// help needed here
   }

Im trying to add an observer , but I can’t figure how to use the object ‘_URL’ as a key for the image.After using the observer to receive the object, I have to find the imagecache for that URL.

  • 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-06-09T16:53:23+00:00Added an answer on June 9, 2026 at 4:53 pm

    You have this code now:

    NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                         image, AsyncImageImageKey,
                                         _URL, AsyncImageURLKey,
                                         nil];
    

    So when you want to add it to the imageCache:

    NSURL *_url = [userInfo objectForKey:AsyncImageURLKey];
    UIImage *image = [userInfo objectForKey:AsyncImageImageKey];
    
    [imageCache setObject:image forKey:_url];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method called ReadTill that has the same body of code but
I have this method that gets called when i press a button and removes
I have a class with this method: def telecom_info Rails.cache.fetch("telecom_info_for_#{ref_num}", :expires_in=> 3.hours) do info
Trying to use GridBagLayout. I have the method called buildLabel. This creates three label.
So I have a simple method called Invert : public static void Invert(this bool
I have a method that is called addHighScore. When a user wants to quit
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I have a controller which has a method called history class UsersController < ApplicationController
Right now I have a table called Campaigns that has many Hits, if I
i have an Autocomplete ajax control that calls a WCF service method automatically. 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.