Compiler error: “initializer element is not a compile-time constant”

When you define a variable outside the scope of a function, that variable’s value is actually written into your executable file. This means you can only use a constant value. Since you don’t know everything about the runtime environment at compile time (which classes are available, what is their structure, etc.), you cannot create objective … Read more

printf(“%%%s”,”hello”)

The compiler simply interprets this as calling printf with two strings as arguments (but see Zack’s comment). This happens at compile time (i.e. the compiler does this): The strings (“%%%s” and “hello”) are copied directly into the executable, the compiler leaves them as-is. This happens at runtime (i.e. the C standard library does this when the app is running): … Read more

Difference between nil, NIL and, null in Objective-C

nil is the literal null value for Objective-C objects, corresponding to the abstract type id or any Objective-C type declared via @interface. For instance: Nil is the literal null value for Objective-C classes, corresponding to the type Class. Since most code doesn’t need variables to reference classes, its use is not common. One example is: NULL is the literal null value for … Read more

“unrecognized selector sent to instance” error in Objective-C

It looks like you’re not memory managing the view controller properly and it is being deallocated at some point – which causes the numberButtonClicked: method to be sent to another object that is now occupying the memory that the view controller was previously occupying… Make sure you’re properly retaining/releasing your view controller.

Xcode build failure “Undefined symbols for architecture x86_64”

It looks like you are missing including the IOBluetooth.framework in your project. You can add it by: Clicking on your project in the upper left of the left pane (the blue icon). In the middle pane, click on the Build Phases tab. Under “Link Binary With Libraries”, click on the plus button. Find the IOBluetooth.framework … Read more