Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sebastienbrault/37d95c0c825f9afaab4e2680c486a848 to your computer and use it in GitHub Desktop.
Save sebastienbrault/37d95c0c825f9afaab4e2680c486a848 to your computer and use it in GitHub Desktop.
How te retrieve the bundle identifier of a specific bundle
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[[NSBundle mainBundle] bundlePath] error:NULL];
for (NSString *fileName in files)
{
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
// do something with `url`
if ([fileName isEqualToString:@"MY_BUNDLE.bundle"])
{
NSLog(@"Found id : %@ for bundle : %@", [[NSBundle bundleWithURL:url] bundleIdentifier], fileName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment