• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] Caching images fetched from a URL?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] Caching images fetched from a URL?


  • Subject: Re: [iPhone] Caching images fetched from a URL?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Wed, 13 May 2009 09:23:15 -0400

Thank you everyone!!!! I have this working (locally in memory anyway)... I
had to tweak the method a little bit...

- (UIImage*)imageNamed:(NSString*)imageNamed cache:(BOOL)cache

{

  UIImage* retImage = [staticImageDictionary objectForKey:imageNamed];

  if (retImage == nil)

  {

   // Since my images are not local, fetch externally

        //retImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]


            pathForResource:imageNamed ofType:nil]];

retImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL

            URLWithString:imageNamed]]];

if (cache)

{

if (staticImageDictionary == nil)

staticImageDictionary = [NSMutableDictionary new];

 [staticImageDictionary setObject:retImage forKey:imageNamed];

}

}

return retImage;

}

And how I am calling it:

UIImage *ret = [self imageNamed:tmp cache:YES];

holder.image = ret;

Seems like it's working pretty well. Although there will always be some
initial stutter on long lists in the table, at least once you've used it a
little things smooth out. If I need to, I'll just use the file system or a
db. Thanks for all of the help here, I really appreciate it!

Eric


On Wed, May 13, 2009 at 12:58 AM, Michael Vannorsdel <email@hidden>wrote:

> The UIImage is the object (inherits from NSObject), so yes you'd pass the
> pointer to it as the dict's object.  And objectForKey: will pass back that
> pointer to the UIImage again.
>
>
> On May 12, 2009, at 10:00 PM, Eric E. Dolecki wrote:
>
>  I like the cache without writing to the disk (for now anyway).
>>
>> When you say the image object itself, I don't know exactly what you
>> mean...
>> if it's just a pointer to UIImage then I think I do know. So I could pair
>> the pointer with the URL key, is that right?
>>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>



--
http://ericd.net
Interactive design and development
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [iPhone] Caching images fetched from a URL?
      • From: Luke the Hiesterman <email@hidden>
    • Re: [iPhone] Caching images fetched from a URL?
      • From: Alex Kac <email@hidden>
References: 
 >[iPhone] Caching images fetched from a URL? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: [iPhone] Caching images fetched from a URL? (From: Dave DeLong <email@hidden>)
 >Re: [iPhone] Caching images fetched from a URL? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: [iPhone] Caching images fetched from a URL? (From: Eric Hermanson <email@hidden>)
 >Re: [iPhone] Caching images fetched from a URL? (From: "Eric E. Dolecki" <email@hidden>)
 >Re: [iPhone] Caching images fetched from a URL? (From: Michael Vannorsdel <email@hidden>)

  • Prev by Date: RE: Updating NSTableView
  • Next by Date: Re: Updating NSTableView
  • Previous by thread: Re: [iPhone] Caching images fetched from a URL?
  • Next by thread: Re: [iPhone] Caching images fetched from a URL?
  • Index(es):
    • Date
    • Thread