What is a identifier ?

I start learning Objective-C and the Xcode is returning errors of identification for the code that I'm developing.

 - (void)mouseDown:(NSEvent *)event;
Use of undeclared identifier 'mouseDown'
NSLog("mouseDown") 

How to identify 'mouseDown" Event and receive a event in the output ?

To answer your immediate question, an identifier is the string used to identify some construct (variable, type, function, whatever) in a program. For example, in the classic first C program:

#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Hello Cruel World!");
    return 0;
}

you have the following identifiers:

  • main, identifying the main function
  • argc and argv, identifying the arguments to that function
  • int and char, identifying types for those arguments
  • printf, identifying a library function

Notably, return is not an identifier, but rather a reserved word.

In the specific example you gave, mouseDown: is actually a method name, which is an identifier of sorts. Objective-C method names are weird because they can be split at the colons. For example, the identifier for this NSString method:

- (instancetype)initWithCharacters:(const unichar *)characters length:(NSUInteger)length;

is initWithCharacters:length:.

As to why you’re getting this error, it’s most likely due the context. This code:

- (void)mouseDown:(NSEvent *)event;

only makes sense within a class interface (@interface) or a class implementation (@implementation).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

What is a identifier ?
 
 
Q