/////////////////////////////////////////
////////////////////////////////////////
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