tags:

views:

83

answers:

1

The compiler complains about this:

int randomSort(id obj1, id obj2, void *context) { // first line
    return (arc4random()%3 - 1);
}

in first line:

_cmd undeclared

and

'self' undeclared (first use in this function)

When I not use arc4random() here, i.e. just return 1, everything is fine. I have other c functions in this file which use arc4random() without problems.

Any idea?

+2  A: 

You need to tell the signature of the arc4random() function before using it, i.e.

int arc4random();  // or whatever it looks like

Or include/import an appropriate header file. If your randomSort function is really the first line, then obviously there is no line before, making it impossible you included/imported that (not regarding precompiled headers here).

Eiko
The appropriate header is stdlib.h. http://developer.apple.com/iphone/library/documentation/system/conceptual/manpages_iphoneos/man3/arc4random.3.html
JeremyP