Library of standard compiler warnings/errors - objective-c

I am wondering whether you know of a way to demystify a given compiler warnings/error Xcode throws at you.
As a new developer to Objective-C, i would find it to be of value to know why some warnings happen, see examples of a code that would cause an error and explain the solution.
Are you aware of any resources that offer more insight into this?

"some warnings happen, see examples of a code that would cause an error and explain the solution."
It's best for you to provide code samples.
Why?
From http://developer.apple.com/library/ios/#documentation/DeveloperTools/gcc-4.2.1/gcc/Standards.html#Standards
"There is no formal written standard for Objective-C or Objective-C++. The most authoritative manual is “Object-Oriented Programming and the Objective-C Language”, available at a number of web sites..."
This means that tt's best for you to provide a specific warning and the associated code.

Related

Objective-C standards document

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
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.
I think I understand your question correctly, so I will answer accordingly...
I highly recommend the documents in the Apple Developer Library. Here are a couple basic guides to get you started:
Concepts in Objective-C Programming
Programming with Objective-C
Cocoa Fundamentals Guide
iOS App Programming
The documents there are the definitive source for Objective-C and Cocoa best practices and coding standards. There are many more documents on a multitude of topics, so make sure to check that website out.
You also asked about how to know what methods are available for objects. To know that, you can check out the Class References.
For example:
NSObject Class Reference
The difference between the guides and the class references is that the guides are more about the concepts behind the code whereas the class references are a list of the methods and properties available for a class.
Hope this helped.
Found at least some of the language definitions of Objective-C, including syntax etc. (see link)
I'm just now where you have been 3 years ago (according to the date in your question): I'm starting to get into Objective-C, and I find it as well strange that there seems to be no reference manual, where I could for example look up the exact meaning and definition of syntax, keywords etc.
I've now discovered, that at least some of it can be found in a document which is related to cocoa (Cocoa Core Competencies). The link for example jumps to the definition of the keyword "#property".
In my POV this is not only relevant only specifically to Cocoa but is generally defining the Objective-C language extension of C. Thats why I wouldn't have searched for it in documents labled "Cocoa ".

Parsing Objective-C code for static analysis

I love static analysis and compile-time checks, almost to a fault, but most of my day job is in Objective-C. To resolve this tension, I'd like to be able to write my own analysis tools that I can run on my Objective-C projects.
But googling around the Internet suggests that people are having a hard time putting together a complete Objective-C grammar. One site basically recommends giving up.
I did find a grammar on the ANTLR website, but when I fired it up, I couldn't get it to parse anything at all. For example, it responded to the line:
void x();
with src/main/resources/somecode.m line 1:0 no viable alternative at input 'void'
:(
I took a closer look at the grammar and found the following disheartening disclaimer:
it's a work in progress, most of the .h file can be parsed
But I need something that can parse both interface and implementation.
Is there a complete Objective-C 2.0 grammar out there somewhere? I'd prefer something that can work with Scala (so anything Java compatible, like ANTLR, would be perfect), but at this point I'd be willing to adapt something designed for another parser toolkit.
As others mentioned, Clang would be the right solution. You can provide your own AST consumers, i.e. classes that will be invoked when going over the AST, leaving you not having to worry about parsing or messing with grammar.
Clang supports Objective-C in its entirety, and there's a lot of classes already in the static analyzer that you can model your own checks after. (in clang/lib/StaticAnalyzer/Checkers).
That directory contains a lot of static analyzer checkers, but you can also just create a normal AST consumer. Refer to http://code.google.com/p/chromium/wiki/WritingClangPlugins for more information.
Clang is a static analysis tool that has support for Objective-C. I've found it very useful in the past.
http://clang-analyzer.llvm.org/
clang is extensible; you can extend their existing static analysis or create your own. llvm / clang is architected as a series of libraries you can link to (dynamically or statically). A great starting point is the ARC (automatic reference counting) migrator library, which is responsible for statically analysing and rewriting objective-c code.
arcmt-test is a small example program that consumes the ARC migrator library.
You can use OCDepend, it's a static analysis tool based on Clang that simplifies managing Objective-C code quality and provides a highly flexible code query framework.

Objective-C implementation of Shape Context algorithm (Image Matching)?

There is a very cool sounding technique called Shape Context matching, which can be used in an Image Recognition application to match an "unknown image" against a known "image library." There are numerous descriptions of the concept documented on the web (mostly all variations of the same original paper), for example: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html
I found a JAVA implementation and a MATLAB implementation of the algorithm described in the paper, but I cannot find an objective-c implementation. Anyone know if there is any objective-c code out there, anywhere, implementing these techniques? I sure would like to take advantage of it, rather than trying to write that stuff myself!
Here you can find an interesting c++ implementation (for non-commercial usage, didn't check it yet.. see the downloads):
http://www.umiacs.umd.edu/~zhengyf/PointMatching.htm
I'm currently searching for a Java implementation of the algorithm. Could you please provide a link to the implementation you found?
The original matlab code can be downloaded at:
www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html
I also found a C# implementation:
http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=7465&lngWId=10
Take a look at OpenCV. It is implemented in C so it can be used in obj-c pretty easily.

GNUstep NSString.m file

I'm using GNUstep to begin with learning Objective-C.
I could find the header files for all, but don't know where to find its implementation files.
I was thinking, with that I can understand the whole programming style and many more.
I am working without mac , so if some body knows about any good tutorials , that i can use to identify structure of every Classes.
For instance, i have to parse an xml file, just to learn,
but don't know where to start.
Without IDE its hard to find out the sequence, and I don't have got access to any tutorials that best explains this, ( all that i get is in accordance with i-Phone and Cocoa. )
I'm concentrating on console programs, so that I can be thorough with the syntax and language.
Pls help me.
http://gnustep.org/ is the best resource for GNUstep related information, including source and documentation.
GNUStep has some tutorials and definitely the source code available.
You will find that there are small bits and pieces where Cocoa has moved on so GNUStep will not recognize new methods and things like properties or any new objective-2.0 stuff and so on.
Where ever you have the source installed, you can find NSString.m here
/path_to_my_src/gnustep/modules/core/base/Source/NSString.m

Programming features missing in C++ and Java

What are the programming features that are missing in C++ and Java ?
For eg. You can't do recursive programming in QBasic ? You can't dynamically allocate memory in QBasic.
What would be the good to have features in C++, Java.
I think Lisp Programmers will be able to add a few.
I miss lambda expressions.
This answer deals only with C++
Things I miss from the syntax, or the standard library:
RegExp as part of the standard library
Threads as part of the standard library
Pointer to member methods (not objects!)
Properties would be nice (I have seen codes that emulate this via C++ preprocessor... note an nice looking code).
Some lower level networking API (sockets!), and higher level API (give me this file from this ftp, submit "this" to this site via POST).
This is the list of things I would like to see, but I assume other people will disagree with me.
Memory garbage collector is nice.
A n interface for a GUI toolkit - let MSVC map it to win32, and on Linux... (good question!)
A stable ABI. In C it's a standard - but on C++ we are still missing a few decades. I want also stable ABI between compilers - I want to compile one library in MinGW, the other with CL and all should work.
This is the list of things I want to see, but I know they will not get away:
Compatibility with C. Really, it's a myth right now. using namespace std killed it.
Include, headers. Most of the information is already available in the DLL/so/a/"library", do we really need to keep this bad decision from 30 years ago? If needed the compilers should keep information in the binaries.
The need for Makefiles - the compiler should be smart enough to know what to do with this code, from the code itself. Pascal is doing it quite good. I think also D.
(I might be wrong, please correct me) The official standard openly and freely available for viewing. Why should I pay for the official papers? Do I need to do it for HTTP? UTF8? Unicode?
I think this is a very subjective question. From a theoretical point of view there's nothing "missing" in Java because you can do everything you want to from the perspective of the outcome as an application.
As with QBasic - recursion may not be possible but that doesn't prevent you from changing your recursive algorithm to an iterative algorithm. Programming language theory tells us that you can do this with every recursive problem. So there's also nothing missing here.
I think what you mean are features that are "nice to have" - and here everyone has to decide for himself. I'd even say there are features in the language which would have been "nice not to have" such as static imports - but again this is my subjective opinion...