iOS Grammar basic Syntax overview

Source: Internet
Author: User

One source code extension

Class II2.1 Definitions
@interface Person:nsobject//class person inheritance NSOBJETCT @end

The methods and properties defined in the class are written in the middle of @interface [email protected]

The @ here is for the compiler to find and pre-compile processing

property declaration of the class

@interface**lastName;
@property int Yearofbirth; base int type, is a value type
@property (readonly) NSString *firstname; is a read-only property
@end

Minus method declaration ( common method also known as Object Method )

@interface person:nsobject-(void) SomeMethod;//void is the return value type -(void) Somemethodwithvalue (SomeType) value; -(void) Somemethodwithfirstvalue: (SomeType) Info1secondvalue: (Anothertype) Info2; @end

Plus method declaration ( class method also known as static method )

@interface nsstring:nsobject+ (ID)string; + (ID) stringwithstring: (nsstring*) astring; @end

Implementation of the class

#import " XYZperson.h " @implementation  @end

Declare class with interface, implement class with implementation.

iOS Grammar basic Syntax overview

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.