xcode Objective C-构建类/对象
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xcode Objective C-构建类/对象相关的知识,希望对你有一定的参考价值。
Example of how to build and call a class or object
//---------------------------------- // Person.h #import <Foundation/Foundation.h> int age; int weight; } -(void) print; -(void) setAge: (int) a; -(void) setWeight: (int) w; @end //---------------------------------- // Person.m // codeTester #import "Person.h" @implementation Person -(void) print{ NSLog(@"I am %i years old and weight %i pounds", age, weight); } -(void) setAge: (int) a{ age=a; } -(void) setWeight: (int) w{ weight=w; } @end //---------------------------------- //how to call #import "Person.h" //dont forget to import it Person *bucky; bucky = [Person alloc]; //give it memory bucky = [bucky init]; //allows us to defualt init metod [bucky setAge:23]; [bucky setWeight:350]; [bucky print];
以上是关于xcode Objective C-构建类/对象的主要内容,如果未能解决你的问题,请参考以下文章
Xcode 8 和 Swift 无法构建 Objective C 模块'FBSDKLoginKit'
Objective C / IOS5 - 根视图 - 从空应用程序模板构建 (XCODE)
升级到 Xcode 10 后,无法快速识别 Objective C 类
如何用XCode创建Objective-c和C++的混编工程?
iOS - Objective-C 关联(objc_setAssociatedObjectobjc_getAssociatedObjectobjc_removeAssociatedObjects)(代