views:

15

answers:

1

Hello,

How to know the contents of NSbundle in XCode Porject??

bcoz issue is, I have placed a config.doc file in resource folder of my XCode project and i want to read the contents of that config.doc file, but it says that config.doc file is not found. How to solve this problem??

This is how my code looks like:

-(void)applicationDidFinishLaunching:(UIApplication*)application
{
 if([NSBundle mainBundle]pathForResource;@"config" ofType:@"doc")!=nil)
  {
  NSLog(@"File Exists");
  }
 else
  {
   NSLog(@"File not found!!");
  }

  NSString *configContents = [[NSBundle mainBundle]pathForResource:@"config" ofType:@"doc"];
  NSLog(@"Contents of config file : %@",configContents);
}

OUTPUT :

File not found!!
Contents of config file :(null)

how to solve this problem?? i'm not able to make where is the mistake.. plz help

Thank You

+1  A: 

You can see the contents of the bundle in the following way :

  1. Expand the "Products" group in xcode
  2. Right click on your_prodcuct.app and click "Reveal in Finder"
  3. In finder right click on your app and click "Show package contents"

Now you can check whether the file actually exists in the bundle or not.

taskinoor
Hey thanks a lots.. but the "config.doc" file does not exists in the bundle.. Can i add it manually??
suse
Got the answer..it gets added to bundle only if we import a file in Resource folder of XCode. If we create the file within Resource folder, it does not add in Bundle, which ideally shouldn't be the case
suse
ya, this is a feature of xcode. and sometimes its helpful too :-)
taskinoor