Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebView using generated HTML string with Images



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.