OC Foundation The second day class and object---1 review code

Source: Internet
Author: User

#import <Foundation/Foundation.h>

@interface Phone:nsobject

{

@public

NSString *_brand;

NSString *_model;

NSString *_color;

float _size;

NSString *_cpu;

}

-(void) aboutmyphone;

Aboutmyphone;

Call.

-(void) Callwithnumber: (NSString *) number;

Callwithnumber:

Texting

-(void) SendMessage: (NSString *) message Tonumber: (NSString *) number;

Sendmessage:tonumber:

@end

@implementation Phone

-(void) Aboutmyphone

{

NSLog (@ "\ n Brand:%@\n model:%@\n color:%@\n Size:%.2f\ncpu:%@",

_brand,_model,_color,_size,_cpu

);

}

-(void) Callwithnumber: (NSString *) number

{

NSLog (@ "Calling%@", number);

}

-(void) SendMessage: (NSString *) message Tonumber: (NSString *) number

{

NSLog (@ "Sending SMS"%@ "to"%@ ", Message,number);

}

@end

Name: Xiao Wang

Age: 19

int main (int argc, const char * argv[])

{

Phone *iphone = [phone new];

Iphone->_brand = @ "Apple";

Iphone->_color = @ "Local tyrants gold";

IPHONE->_CPU = @ "A7";

Iphone->_model = @ "IPhone 8S";

Iphone->_size = 7.9f;

[IPhone Aboutmyphone];

[IPhone callwithnumber:@ "10086"];

[IPhone sendmessage:@] See you at the old place tonight! "tonumber:@" 110 ";

return 0;

}

OC Foundation The second day class and object---1 review code

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.