views:

149

answers:

1

Hi I need to cache images locally and was thinking about saving them as SerializableDictionary

SerializableDictionary is from: http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx

I was wondering if this was

a: a good way of handling caching of images (for offline mode - the data is constantly updated so pulls from the web first).

b: how can i do this?

I seem to be only left with the following xml:

    <?xml version="1.0" encoding="us-ascii"?>
<dictionary>
  <item>
    <key>
      <string>http://img.theguidestar.com/thumb/491520.png&lt;/string&gt;
    </key>
    <value>
      <UIImage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
        <Handle />
        <Size>
          <Width>0</Width>
          <Height>0</Height>
        </Size>
      </UIImage>
    </value>
  </item>
</dictionary>

Is there anything specific i should be doing to make it serialize the image itself?

w://

A: 

UIImage and CGIMage don't allow easy access to their data. So, it is pretty difficult to serialize image in a XML document.

You can use the following solution:

  • Retrieve the image from the network and store them in the user's document folder.
  • Map the URL of the image to the local path of the image in a Dictionary.
  • Use the Dictionary as the cache index to access the images.
Laurent Etiemble
this is pretty much what i ended up doing. redth hsa a nicer image cache here: http://github.com/Redth/MonoTouch.Dialog.UrlImageStore
cvista