Obj-c class

Source: Internet
Author: User

1. Create Class 2. Encapsulation class. h @interface (interface) 2.1 declares a member variable {variable list} 2.2 declares a function-(return type) method name: (parameter type) parameter 1 Label: (parameter type) parameter 2;. m @impleme Ntation (enable) Implementation function 3. Create an object using a class: class name * Object name = [[Class name alloc] init]; Alloc: class opens space init; object initialization @public//Common type access: both inside and outside of the class Member variables that can be accessed
@protected//Protected Access: A modified member variable that accesses access to the @private//private type in both the inside of the class and in the child class ... Member variables that are accessible only within the class #import <Foundation/Foundation.h> #import "Student.h"reference function to write header file#import"Game.h"
#import "Car.h"
/*
Introduce the header file: The difference between the left and # include is that import does not cause cross-compilation, and that the class you create is generally "" ... framework of the system with < >

*/
int main (int argc, const char * argv[])
{@autoreleasepool {//auto-free pool manages memory for user/*

Class name * object name; equal to int A;

NSString *[email protected] "Tom";//String plus * is Object-oriented NSString is a string class different from Char


NSLog (@ "name is a string:%@", name); The standard output function wraps automatically.

Nsarray *[email Protected][name,name,name];
NSLog (@ "Array is a array:%@", array);

For (NSString *str (self declared variable) in array)//loop traversal
{
NSLog (@ "For in%@", str);
}

*/

Obj-c class

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.