• 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: WebView using generated HTML string with Images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebView using generated HTML string with Images


  • Subject: Re: WebView using generated HTML string with Images
  • From: "Joe Goh" <email@hidden>
  • Date: Sun, 27 May 2007 09:19:05 +0800

On 5/27/07, Steve Sheets <email@hidden> wrote:
When this code originally started, I tried to use Web Resources to do what
you described. However, after advice from other programmers, I was told not
to attempt this since there was no good way to create a Web Archive or Web
Resource.

Actually, its pretty easy to create a WebResource. This is code taken from my app (with variable names slightly modified).

WebResource *myWebResource = [[WebResource alloc] initWithData:yourImageData

   URL:sourceURL

MIMEType:mimeType

textEncodingName:nil

frameName:nil];

[[[self mainFrame] dataSource] addSubresource:myWebResource];

I understand how to add the SubResource, but what do you mean
about "generate a unique URL for each image.". This is the part that
confuses me

The URL used in the initWithData: method must be unique because WebKit would otherwise confuse the images you're sending to it.

Basically, for each image that you're sending to WebKit, just create a
unique URL in the form of an NSString for it, something like this:

x-coredata://F977925C-C8F3-4BD0-B37A-D8F85853267F/Attachment/p9

This is actual output from my app.  This is really easy to generate if
you're using CoreData, as CoreData has a URIRepresentation method that
does this automatically.

Have fun!
Joe Goh
FunkeeMonk Technology
http://www.funkeemonk.com/
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Re: NSLocalizedStringFromTableInBundle not returning localized string
  • Next by Date: Bindings
  • Previous by thread: Re: NSLocalizedStringFromTableInBundle not returning localized string
  • Next by thread: Bindings
  • Index(es):
    • Date
    • Thread