Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add basic token replacement to our custom HTML.

  • Loading branch information...
commit 9e133e4c96b8354392263681562478db6901ceeb 1 parent b05e94e
@dannygreg authored
Showing with 14 additions and 2 deletions.
  1. +12 −1 AppDelegate.m
  2. +2 −1  cover.html
View
13 AppDelegate.m
@@ -14,6 +14,8 @@
#import <QTKit/QTKit.h>
#import <WebKit/WebKit.h>
+NSString *const AppDelegateHTMLImagePlaceholder = @"#{IMAGE_URL}#";
+
@implementation AppDelegate
@synthesize window = _window;
@@ -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
View
3  cover.html
@@ -1,4 +1,5 @@
<html>
<body>
-<p>Hello World!</p>
+ <p>Hello World!</p>
+ <img src="#{IMAGE_URL}#">
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.