开发者

How to get resources path?

开发者 https://www.devze.com 2023-01-05 05:39 出处:网络
I run my app on Simulator in XCode and it works fine but when I try to ru开发者_Go百科n it on the device it doesn\'t work.

I run my app on Simulator in XCode and it works fine but when I try to ru开发者_Go百科n it on the device it doesn't work. I figured out that it doesn't open some files. (I don't know if it gets wrong path or maybe the files aren't copied)

Before I open my files I get their path like that:

const char* Pobierz_sciezke(const char  *tytul_c)
{
 NSString *tytul = [NSString stringWithUTF8String: tytul_c];

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0];

 NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:tytul];

 if (![[NSFileManager defaultManager] fileExistsAtPath:myPathDocs])
 {
  NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"tex_dane" ofType:@"txt"];
  NSFileManager *fileManager = [NSFileManager defaultManager];
 }

 NSLog(@"%@",myPathDocs);

 const char *sciezka;
 sciezka = [myPathDocs UTF8String];
 return sciezka;
}

Is this code ok?

Maybe I should add my resources in a different way? Change project settings?

0

精彩评论

暂无评论...
验证码 换一张
取 消