I’m learning the basics of objective-C by Reading ‘Objective C For Dummies’.
I’m using XCode 4.4, and I’m trying to get some simple code to work. This question has been posed online before. However – the code doesn’t seem to compile with the new version of XCode.
At issue seems to be the line NSLog (@”Here is some amazing text! %i”,c); This throws an ‘Expected Expression’ Error. Per the previous form posting, I have disabled automatic reference checking in preferences and this still fails.
#include <stdio.h>
int main(int argc, const char * argv[])
{
//declare variables
int a;
int b;
int c;
//set the variables
a = 2;
b = 3;
//Perform the computations
c = a % b;
//Output the results
NSLog (@"Here is some amazing text! %c",c);
return 0;
}
Add
#import <Foundation/Foundation.h>at the top, and change theNSLogto this:Because
%cdoesn’t mean “a variable calledc“, but rather achar.%dmeans anint, which is whatcis.