Comments in NS prefix \OC \ Access functions in OC Original file, c original file

Source: Internet
Author: User

/////////////////////////////////////////

////////////////////////////////////////

NS Prefix

NS a software from NeXTSTEP NeXT software

Namespaces not supported in OC (namespace)

NS is a prefix that is given to avoid naming conflicts

See the NS prefix to know the name of the system class in cocoa

How to use "@"

1, @ "" is a symbol that converts a string in C to a string object in OC

2, the @ symbol OC Most of the keywords are at the beginning of the @, such as @interface

@[email protected] @class

/////////////////////////

////////////////////////

Comments in OC

1) Single-line comment://

2) Multi-line Comment:/* */

No comments are processed when the program is compiled

Note You can appear in most of the program's locations.

///////////////////////

//////////////////////

Access to functions in OC Original file, c original file

Oc.m

//

Main.m

Hello World

//

Created by Angel on 15-7-14.

Copyright (c) year Angel. All rights reserved.

//


#import <Foundation/Foundation.h>


void Test_oc () {

printf(" i am a function of OC");

NSLog(@ " i am nslog\n");

}


Main.m

int Main (int argc, const Char * argv[])

{


@autoreleasepool {

//Insert code here ...

//nslog (@ "Hello, world!");

// usage

NSLog(@ "This is a Test"); // Print a string

nsstring *str=@ "Hello iphone";

NSLog(@ "string is:%@", str); use a placeholder,%@ to print an object

NSLog (@ "a=%d,b=%d",ten);

}

return 0;

}

TEST.c

//

TEST.c

Hello World

//

Created by Angel on 15-7-14.

Copyright (c) 2015 Angel. All rights reserved.

//


#include "test.h"

void Test_c ()

{

printf ("I am C function");

}

Oc.h

//

Oc.h

Hello World

//

Created by Angel on 15-7-14.

Copyright (c) 2015 Angel. All rights reserved.

//


#ifndef Hello_world_oc_h

#define Hello_world_oc_h

void Test_oc ();

#endif

Test.h

//

Test.h

Hello World

//

Created by Angel on 15-7-14.

Copyright (c) year Angel. All rights reserved.

//


#ifndef Hello_world_test_h

#define Hello_world_test_h

Test_c () function declaration

#include<stdio.h>

#endif


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Comments in NS prefix \OC \ Access functions in OC Original file, c original file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.