今天刚弄来个苹果,跟着视频来写了程序试试,看看程序教程和自己动手写程序是不一样的,一点点小失误就会出现错误,比如今天的对象被我打成了类名称,就能不能调用类的行为
- #import <Foundation/Foundation.h>
- #import "Person.h"
- int main(int argc, const char * argv[]) {
- //创建person的实例对象
- Person *person = [[Person alloc] initWithName:@"lewis"];
- //给person发送实例消息sayHi
- [Person sayHi];//整行应该改为[person sayHi];
-
-
- //打印当前person实例对象的姓名是什么
- NSLog(@"person's name is %@",[person getName]);
-
- //修改当前person实例对象的姓名,修改成Jack
- [person setName:@"Jack"];
-
- //打印当前实例对象的姓名
- NSLog(@"perspn's name is %@",[person getName]);
-
- /*
- @autoreleasepool {
- // insert code here...
- NSLog(@"Hello, World!");
- }
- */
-
- return 0;
- }
复制代码 |
|