iOS New Year review

Source: Internet
Author: User

1. How to define an OC class

@interface Class Name: Parent class name

{

instance variables (not recommended in. h files, written in the extension of. m)

If the subclass is to inherit, it must be written in. h

}

@property

Method

@end

2. Attributes and instance variables

property is a set of getter and setter

3. Initialization method

-(Id/instancetype) initwithxxx

Specifying the initialization method

4. Convenience Builder

Special initialization method for Alloc and Autorelese (easy memory management)

5.Category

Classification, extension class. More than a good existence.

Syntax format

@interface class name (category name)

@end

@implementation class name (category name)

@end

6. One OC Class (Cup)

//

CUP.h

CUP

//

Created by Carl_fang on 15/3/2.

Copyright (c) 2015 Carl_fang. All rights reserved.

//

#import <Foundation/Foundation.h>

@interface Cup:nsobject

@property (nonatomic) float price;

-(Instancetype) Initwithvolume: (Nsinteger) Volume Brand: (NSString *) brand;

+ (CUP *) Cupwithvolume: (Nsinteger) Brand: (NSString *) brand;

-(void) Fillinwater: (Nsinteger) volume;

@end

7. Memory Management

Focus: Reference counting

Autorelese

iOS New Year review

Related Article

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.