Re: Bundle Identifiers - and application support directory
Re: Bundle Identifiers - and application support directory
- Subject: Re: Bundle Identifiers - and application support directory
- From: Mike Abdullah <email@hidden>
- Date: Wed, 10 Jul 2013 14:33:30 +0100
On 10 Jul 2013, at 11:25, Peter Hudson <email@hidden> wrote:
> I am trying to create an application support directory for my app ( on 10.8.3 )
>
> I am using this piece of example code ( from the docs ) :-
>
>
>
> NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier];
> NSFileManager*fm = [NSFileManager defaultManager];
> NSURL* dirPath = nil;
>
> // Find the application support directory in the home directory.
> NSArray* appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory
> inDomains:NSUserDomainMask];
> if ([appSupportDir count] > 0)
> {
> // Append the bundle ID to the URL for the
> // Application Support directory
> dirPath = [[appSupportDir objectAtIndex:0] URLByAppendingPathComponent:bundleID];
>
> // If the directory does not exist, this method creates it.
> // This method call works in OS X 10.7 and later only.
> NSError* theError = nil;
> if (![fm createDirectoryAtURL:dirPath withIntermediateDirectories:YES
> attributes:nil error:&theError])
> {
> // Handle the error.
> }
> }
>
>
> When I run the code, bundleID is nil.
> Is there something that I have to do to give my bundle an ID ?
> I have checked the methods of NSBundle ( and NSBundle docs generally ) but cannot see anything that looks promising.
The bundle ID is set in your app's Info.plist. I'm surprised that Xcode will even let you build an app without one though.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden