This is really simple but driving me nuts.
I am trying to implement a simple function in my Objective-C code. When I write this,
NSInteger Sort_Function(id id1, id id2, void *context) {
}
I get an error that a semi-colon was expected at the end of the declaration. However, I’ve seen this type of syntax in many, many examples. What could I possibly be doing wrong? If it matters, this is an iOS app and the function is nested in an if clause. Thanks in advance.
The function definition — this snippet you posted — is “nested in a
ifclause”? That’s unfortunately illegal in C (and Obj-C by extension) — all function declarations and definitions have to be at the top level of the file. Inside an@implementationsection is also an option:Is it possible you’re confusing the function syntax with block syntax?