0

Following an answer I found here: https://stackoverflow.com/a/18121292/1701170, I have the following code:

bool accessibilityEnabled = false;

// Check and make sure assistive devices is enabled.
if (AXIsProcessTrustedWithOptions != NULL) {
    // 10.9 and later
    NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
    accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
} else {
    // 10.8 and older
    if (AXAPIEnabled() == true) {
        accessibilityEnabled = true;
    }
}

if (accessibilityEnabled) {
    // do something
}

The error I get is as follows:

[apply] error: use of undeclared identifier 'NSDictionary'; did you mean 'UseDictionary'?
[apply]         NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
[apply]         ^~~~~~~~~~~~
[apply]         UseDictionary

Do I have to import NSDictionary?

The imports at the top of the file are as follows:

 #include <pthread.h>
 #include <sys/time.h>

 #include <ApplicationServices/ApplicationServices.h>

 #include "NativeErrors.h"
 #include "NativeGlobals.h"
 #include "NativeHelpers.h"
 #include "NativeThread.h"
 #include "NativeToJava.h"
 #include "OSXInputHelpers.h"

This is my first time looking at Objective-C.

Community
  • 1
  • 1
tadasajon
  • 14,276
  • 29
  • 92
  • 144

1 Answers1

3

The project you linked looks like a plain C project to me. NSDictionary is an Objective-C class and part of the Foundation framework from Apple. You have to link Foundation.framework and make sure it is imported in your source. If you're just experimenting, your best bet would probably be to just create a new project in Xcode using the Command Line Tool (of type Foundation) template.

DrummerB
  • 39,814
  • 12
  • 105
  • 142
  • Thanks. I'm probably in over my head. The project I linked to won't complile on OS X 10.9 and I'm trying to put in a simple patch, but I may not understand the context well enough. – tadasajon Dec 11 '13 at 19:54