New in Objective-c, Hello World

I am just starting to learn Objective-C programming. I am developing in Xcode 4.2 on Mac OS X version 10.7.2 on iMac. I am reading Stephen Cochan's book Objective-C Programming, which contains a simple Hello World example:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSLog (@"Hello, World!");
    [pool drain];
    return 0;
}

When compiling, many errors are reset:

/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.hhaps13:19: error: unknown type name 'NSString' [1]

There are many more. Is there something you need to do before compiling for the first time? Some settings in Xcode?

+5
source share
4 answers

Unknown typename NSString , c- () c-

+6

, , . , -, c

File → new project Cocoa Application .

'didFinishLaunchingWithOptions' appdelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSLog (@"Hello, World!");
    [pool drain];
    return YES;

}

. Hello World .

+1

. , , " ", "Core Foundation", "Foundation" , . . !

0

Download sample code and applications for Windows 8, Windows Phone, Microsoft Azure, Office, SharePoint, Silverlight, and more. You can also learn the official Visual Studio C #, VB.NET, and 101 LINQ examples. dca056 dcba56 dcvb56

0
source

All Articles