Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:59:26+00:00 2026-05-28T16:59:26+00:00

My application uses the following code : #if MAC_OS_X_VERSION_10_5 < MAC_OS_X_VERSION_MAX_ALLOWED NSArray *globalPreferencePanes =

  • 0

My application uses the following code:

#if MAC_OS_X_VERSION_10_5 < MAC_OS_X_VERSION_MAX_ALLOWED
    NSArray *globalPreferencePanes = 
        NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory,
            NSAllDomainsMask, YES);        
#else
    NSArray *globalPreferencePanes = 
        [NSArray arrayWithObjects:@"/Library/PreferencePanes", 
            [@"~/Library/PreferencePanes" stringByExpandingTildeInPath], nil];
#endif
return globalPreferencePanes;

The project under which I’m compiling this is aimed at the 10.5 Mac OSX SDK, where NSPreferencePanesDirectory does not exist (it only exists in 10.6+). Because of this, I have the #if and #else in order to check what version of Mac OSX we’re running under, so I know whether I should use the NSPreferencePanesDirectory or just manually give the location of the preference pane directories.

What should I change in order to stop getting this “use of undeclared identifier” error?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:59:26+00:00Added an answer on May 28, 2026 at 4:59 pm

    #if is evaluated at compile time, not run time. What you probably want to do is use the current SDK (10.7), and do something like this:

    NSArray *globalPreferencePanes;
    
    if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_6)
        globalPreferencePanes = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSAllDomainsMask, YES);        
    else
        globalPreferencePanes = [NSArray arrayWithObjects:@"/Library/PreferencePanes", [@"~/Library/PreferencePanes" stringByExpandingTildeInPath], nil];
    
        return globalPreferencePanes;
    

    Making sure to set your target OS version to 10.5 so the symbol is weak linked. Otherwise, you could drop down and use CoreServices’ FSFindFolder():

    NSMutableArray *globalPreferencePanes = [NSMutableArray array];
    FSRef foundRef;
    
    OSErr err = FSFindFolder(kLocalDomain, kPreferencePanesFolderType, false, &foundRef);
    
    if (err != noErr) {
        CFURLRef url = CFURLCreateFromFSRef(NULL, &fsRef);
        CFStringRef path = CFURLCopyPath(url);
        [globalPreferencePanes addObject:(id)path];
        CFRelease(path);
        CFRelease(url);
    }
    
    OSErr err = FSFindFolder(kUserDomain, kPreferencePanesFolderType, false, &foundRef);
    
    if (err != noErr) {
        CFURLRef url = CFURLCreateFromFSRef(NULL, &fsRef);
        CFStringRef path = CFURLCopyPath(url);
        [globalPreferencePanes addObject:(id)path];
        CFRelease(path);
        CFRelease(url);
    }
    
    return globalPreferencePanes;
    

    (Not tested)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Windows Forms application uses the following standard line of code so that visual
I have a Lisp (SBCL 1.0.40.0.debian) application (myfitnessdata), which uses the following code to
My Ruby on Rails application uses the following controller code to generate a sitemap.xml
The following code exists in LogEntry.cs in the Enterprise Library's Logging Application Block: private
I have the following problem deploying my application. It uses JMS and a remote
I am getting the following error while running my MVC application, which uses the
I am developing grails application which uses file searching.For that I wrote the following
I have existing code for an ASP .NET application that uses reflection to load
We are trying to write an application that uses the NServiceBus library in a
I my application I have written following code in order to extract phone number.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.