kwigbo

Adventures in iOS!

0 notes &

iPhone SDK Get Path For File

Here are two snippets that show how to get the path for a file in the documents directory or the main bundle.

// Main Bundle
NSString *pathInMainBundle = [[NSBundle mainBundle] 
		pathForResource:@"example" ofType:@".png"];
 
// Documents Directory
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
		NSUserDomainMask, YES);
 
NSString *docsDir = [documentPaths objectAtIndex:0];
NSString *pathInDocuments = [docsDir 
		stringByAppendingPathComponent:@"example.png"];

Filed under snippet iphone iphone dev