grabbing data from an internal file

265 views Asked by At

I'm grabbing data from an external file using NSURL with the code below. If i wanted to grab this data from an internal file in my resources folder how would the code be different.

here's the NSURL code:

NSURL *dataUrl = [NSURL URLWithString:@"https://sites.google.com/site/*****/***/file.asc"]; NSString *fileString = [NSString stringWithContentsOfURL:dataUrl encoding:NSUTF8StringEncoding error:nil];

this was my attempt:

NSString *path = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"asc"]; NSString *fileString = [NSString initWithContentsOfFile:path];

thanks in advance

1

There are 1 answers

2
filipe On BEST ANSWER

Maybe try stringByExpandingTildeInPath
something like

    NSString *path = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"asc"];
    path = [path stringByExpandingTildeInPath];
    NSString *fileString = [NSString initWithContentsOfFile:path];