Thanks Mike.  I have now set an ID for my bundle and it is feeding through 
happily.

Now I can set an ID,  the docs suggest the format     
com.companyDomainName.appName   for the directory name in Application Support.
I notice that very few other applications use this format - they tend to use 
just the name of the app.

Is there a good reason to follow the suggested naming convention ?

Peter



On 10 Jul 2013, at 14:33, Mike Abdullah <mabdul...@karelia.com> wrote:

> 
> On 10 Jul 2013, at 11:25, Peter Hudson <peter.hud...@me.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to