Search code examples
iphoneobjective-cnsbundle

NSBundle returns nil


I wanted to read version information of my application from the plit file.

For this I am using a code as shown below.

NSString *myFilePath = [[NSBundle mainBundle]
                                pathForResource:@"MyApp-Info"
                                ofType:@"plist"];

        // Format output

        NSLog(@"%@",myFilePath);

The output

 2010-08-31 17:14:10.095 MyApp[8759:20b] (null)

It always returns nil even if I tried to Import an existing file of type, text.txt still return nil, where text.txt is imported in the application.

I have goggled for the problem dont every one recommends to use NSBundel to read an pre imported file, but no use.

Any help, or an better way to read application version.


Solution

  • Got the solution via another link in the stack overflow here.

    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    
    
            NSLog(@"%@",version);