Skip to content

Commit

Permalink
Add basic token replacement to our custom HTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
dannygreg committed Feb 18, 2012
1 parent b05e94e commit 9e133e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion AppDelegate.m
Expand Up @@ -14,6 +14,8 @@
#import <QTKit/QTKit.h>
#import <WebKit/WebKit.h>

NSString *const AppDelegateHTMLImagePlaceholder = @"#{IMAGE_URL}#";

@implementation AppDelegate

@synthesize window = _window;
Expand Down Expand Up @@ -54,7 +56,16 @@ -(void) setTheLoopCount:(int)theLoopCount
- (void)awakeFromNib
{
NSURL *htmlFileURL = [[NSBundle mainBundle] URLForResource:@"cover" withExtension:@"html"];
[self.coverWebView setMainFrameURL:[htmlFileURL absoluteString]];
NSError *err = nil;
NSMutableString *html = [NSMutableString stringWithContentsOfURL:htmlFileURL encoding:NSUTF8StringEncoding error:&err];
if (html == nil) {
//Do something with the error
NSLog(@"%@", err);
return;
}

[html replaceOccurrencesOfString:AppDelegateHTMLImagePlaceholder withString:@"blah" options:0 range:NSMakeRange(0, html.length)];
[self.coverWebView.mainFrame loadHTMLString:html baseURL:nil];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
Expand Down
3 changes: 2 additions & 1 deletion cover.html
@@ -1,4 +1,5 @@
<html>
<body>
<p>Hello World!</p>
<p>Hello World!</p>
<img src="#{IMAGE_URL}#">
</body>

0 comments on commit 9e133e4

Please sign in to comment.