MrHappyAsthma
MrHappyAsthma

Reputation: 6522

Get name of Xcode Project in actual code

So you know the part of the project that is "MyNameGoesHere.app" or "MyNameGoesHere.xcodeproj" - is there a way to get the MyNameGoesHere part via objective-c code?

I can get all kind of device info from UIDevice messages but I can't figure out how to get project/app name.

Upvotes: 2

Views: 3369

Answers (2)

derpoliuk
derpoliuk

Reputation: 1816

CFBundleDisplayName doesn't work anymore. Use:

NSString *bundleName = [[NSBundle mainBundle]
                         objectForInfoDictionaryKey:@"CFBundleName"];

Upvotes: 6

XCool
XCool

Reputation: 996

You're probably looking at the bundle's InfoDictionary. You can get the app's name via the following code:

NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSString *bundleName = [NSString stringWithFormat:@"%@", [info objectForKey:@"CFBundleDisplayName"]];

Upvotes: 5

Related Questions