blob: cac24a636a9c75d47935566b301f31f8e1120cfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
//
// OHPathHelpers.m
// Pods
//
// Created by Olivier Halligon on 18/04/2015.
//
//
#import "OHPathHelpers.h"
NSString* OHPathForFile(NSString* fileName, Class inBundleForClass)
{
NSBundle* bundle = [NSBundle bundleForClass:inBundleForClass];
return OHPathForFileInBundle(fileName, bundle);
}
NSString* OHPathForFileInBundle(NSString* fileName, NSBundle* bundle)
{
return [bundle pathForResource:[fileName stringByDeletingPathExtension]
ofType:[fileName pathExtension]];
}
NSString* OHPathForFileInDocumentsDir(NSString* fileName)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *basePath = (paths.count > 0) ? [paths objectAtIndex:0] : nil;
return [basePath stringByAppendingPathComponent:fileName];
}
NSBundle* OHResourceBundleForClass(NSString* bundleBasename, Class inBundleForClass)
{
NSBundle* classBundle = [NSBundle bundleForClass:inBundleForClass];
return [NSBundle bundleWithPath:[classBundle pathForResource:bundleBasename
ofType:@"bundle"]];
}
|