Objective C in New job #method

Mario tsai
Sep 3, 2021

--

Big company has lots of ObjC code

/## Swift

class Person: NSObject {

var _name: String

init(name: String){

_name = name

}

function setName(name:String){

_name = name

}

}

run in playground

Person.setName(“Dancer”)

/##ObjC

@interface Person : NSObject {

NSString* _name;

}

-(void)setName: (NSString*) name;

-(NSString*) name;

@end

@Implementation Person

-(void)setName: (NSString * )name {

_name = name;

}

-(NSString*) name {

return _name;

}

Actually, run in Main.m

Person* p1 =[Person new];

[p1 setName:@”Dancer”];

NSLog(@”%ld”, [p1 age]);

--

--

Mario tsai
Mario tsai

Written by Mario tsai

Major in physical education. Football referee. And high interest in looking the world through the numbers.

No responses yet