I'm a C and C++ programmer trying to get started with Objective-C. I'm really bewildered, though, by the apparent total absence of a standards document for the language and standard library. I can understand that there's no ISO standard, but is there no reference document at all? And how is it that nobody seems very concerned about this state of affairs? (Admittedly, it's hard to Google for such a thing, because "reference", "document", and "standard" are all overloaded terms. So it's possible that I've just missed something critical.)
This question gets close to asking the same thing: Where can i find a document explaining how Objective-C is implemented and the only answer provided was "read this source code published by Apple which is pretty close to what their implementation did a few years ago, maybe".
This page: http://clang.llvm.org/docs/ObjectiveCLiterals.html includes a snippet of a formal grammar for Objective-C, but ironically it's in the context of describing a feature that Clang just went off and added on their own and that nobody else supports. There's another grammar here: http://www.omnigroup.com/mailman/archive/macosx-dev/2001-March/022979.html but it's more than 10 years old.
To narrow the question down to the barest minimum: I'd like to know what methods are guaranteed to be provided by "Object", and what the behavior of each method is. For other languages, this type of information is usually provided by something like this: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html
Furthermore, Objective-C is a piece of art, creators packed genius solutions and were constantly improving it, so us developers were able to use it at our advantage. There are a lot of indicators telling us there's still a ton of legacy Objective-C code, both from Apple and from other developers, that's still in use.
In order to get full features of Objective-C, download and install GNUStep. This can be done by downloading the package from http://main.gnustep.org/resources/downloads.php.
Objective-C is general-purpose language that is developed on top of C Programming language by adding features of Small Talk programming language making it an object-oriented language. It is primarily used in developing iOS and Mac OS X operating systems as well as its applications.
Library use. Objective-C today is often used in tandem with a fixed library of standard objects (often known as a "kit" or "framework"), such as Cocoa, GNUstep or ObjFW. These libraries often come with the operating system: the GNUstep libraries often come with Linux -based distributions and Cocoa comes with macOS.
It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods.
Likewise, the language can be implemented atop extant C compilers (in GCC, first as a preprocessor, then as a module) rather than as a new compiler. This allows Objective-C to leverage the huge existing collection of C code, libraries, tools, etc. Existing C libraries can be wrapped in Objective-C wrappers to provide an OO-style interface.
When writing Objective-C code, you should keep in mind a number of established coding conventions. Method names, for example, start with a lowercase letter and use camel case for multiple words; for example, doSomething or doSomethingElse.
Unfortunately there is no Standard for ObjC as there is for C++ or C. Apple being the main user and driver behind the language, their compiler implementation (the ObjC bits of Clang) is the de facto Standard. Their old document (broken link) "The Objective-C Programming Language" was about as close as you got to a prose version, and it was nowhere near the precision of either of those other languages' Standards (and it tends to lag behind the compiler).
It may still be floating around on the web somewhere, but it is no longer up-to-date. "Programming with Objective-C" seems to be their intended replacement (but again, it's nothing like a standard).
Regarding your comment (10k link only) under Tim's deleted answer, the Cocoa root class is NSObject
, and its interface is documented, but its source is not available. Note that the NSObject
protocol is also an extremely important part of a Cocoa object's functionality. Apple's runtime is open-source,* and has a root class called Object
, I assume for purposes of demonstration. It's not used in Cocoa programming.
You already know about all of this, of course. The direct answer to your question is, "there isn't one". Most of the syntax is the same as C, though, as bbum points out: Authoritative description of ObjectiveC string literals? (yes, I copy-pasted my comment from there into the beginning of this answer).
*Note that contrary to what you say in your question, this is the actual, up-to-date, runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With