Find actual path of resource files in iPhone

Forum for Objective-C iPhone games and OpenGL related topics including programming doubts, books and other resources for iPhone game development

Find actual path of resource files in iPhone

Postby DevelopmentTeam » Tue Oct 07, 2008 10:50 am

This is the code you have to use to find the actual path of the application

Code: Select all
   char *filename;
   NSString *filepath = [[NSBundle mainBundle] bundlePath];
   sprintf(filename, "%s/%s", [filepath cStringUsingEncoding:1], "filename.ext");
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India

Re: Find actual path of resource files in iPhone

Postby DevelopmentTeam » Wed Oct 08, 2008 10:25 am

The code above gave some problem and the debugger got quit. Here is the fix for the code.
This code converts NSString to char* smoothly.

Code: Select all
   NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
   char *filename = (char*)[bundlePath cStringUsingEncoding:1];
   strcat(filename, "/shuttle.obj");
   
   printf("filename:%s\n", filename);
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to iPhone OpenGL ES 3D Game Development Forum

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron