Objective C in New job #method
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]);