object-c review
Posted 再前一步~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了object-c review相关的知识,希望对你有一定的参考价值。
// // main.m // cmdTry // // Created by Calos Chen on 2017/8/21. // Copyright © 2017年 Calos Chen. All rights reserved. // #import <Foundation/Foundation.h> @class Fraction; @interface Fraction : NSObject { int numberator; int denominator; NSString* name; double price; Fraction *myf; } @property double price; -(void) print; -(void) setNumberator: (int)n; -(void) setName: (NSString*)na; -(void) setInfo: (int) id name:(NSString*)name; @end @implementation Fraction @synthesize price; -(void) print { NSLog(@"%i it is %@",numberator,name); } -(void) setNumberator:(int)n { price=5; numberator=n; } -(void)setName:(NSString *)na{ name=na; } -(void) setInfo:(int)id name:(NSString *)na{ id=id; name=na; } @end //---- program section ---- int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); NSLog(@"who are you!"); } NSLog(@"why is it"); Fraction *myf= [[Fraction alloc] init]; [myf setName:@"calos"]; [myf print]; int a1=5; float a2=3.23; double a3=3.44; char a4=‘c‘; int a5=(int)a2; for (int b=1; b<10;b++ ) { a5+=b; } myf.price=88; double b1=myf.price; BOOL isPrime=NO; NSLog(@"%i %f %e %c %i %c %g",a1,a2,a3,a4,a5,isPrime,b1); NSLog(@"end........"); return 0; } //for today: 2017-08-21, I have read and practiced the first 153 pages of the object-c 2.0, now, I have known object-c classes and data types, and how to announce and implement the classes and class members, as well as functions in the class implementation. also property synthesize methods. loops. //homework: implement a new class, and new interface and fill the class with members and all tangible members, then use all of them. @class declaration. So, write a console program with object-c.
以上是关于object-c review的主要内容,如果未能解决你的问题,请参考以下文章