Last active
December 14, 2015 20:09
-
-
Save timd/5141930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assume Xcode project file structure like: | |
Project/ | |
- project.xcworkspace | |
- project.xcodeproj | |
- Project/ | |
- assets/ | |
- data/ | |
- css/ | |
- html/ | |
- content.html | |
- en.lproj/ | |
- main.m | |
- etc | |
- etc | |
To list the contents of the assets/ directory : | |
NSString *filesPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"assets"]; | |
NSArray *filesList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filesPath error:nil]; | |
NSLog(@"filesList = %@", filesList); | |
To list contents of assets/data directory: | |
NSString *filesPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"assets"]; | |
NSArray *filesList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filesPath error:nil]; | |
NSLog(@"filesList = %@", filesList); | |
To load content.html: | |
NSString *pathToBundle = [[NSBundle mainBundle] resourcePath]; | |
NSURL *baseURL = [NSURL fileURLWithPath:pathToBundle]; | |
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"content" ofType:@"html"]; | |
NSString *htmlFileToDisplay = [[NSString alloc] initWithContentsOfFile:pathToFile]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment