无题
来源:互联网 发布:叮叮软件定位查询 编辑:程序博客网 时间:2024/06/05 05:39
今天定义了一个person类和方法,在主程序中引用输出,结果就出现了thread 1 signal sigabrt ;
先在主程序中引入头文件:#import "Person.h"
主程序: Person * kenan = [[Person alloc] init];
[kenan setName:@"我就是死神小学生:柯南"];
NSLog(@"%@", [kenan name]);
#import <Foundation/Foundation.h>
@interface Person :NSObject
{
NSString *_name;
}
- (id)PersonWithName:(NSString *)name;
+ (id)PersonWithName:(NSString *)name;
-(void)setName:(NSString *)name;
-(NSString *)name;
//用便利构造器方法创建对象
@end
person.m
#import "Person.h"
@implementation Person
- (id)initWithName:(NSString *)name{
self = [superinit];
if (self) {
_name = name;
}
return self;
}
+ (id)PersonWithName:(NSString *)name{
Person *p = [[Personalloc]initWithName:name];
return p;
}
//- (void)setName:(NSString *)name{
// _name = name;
//}
//原因是少写了这一被注释的部分
//-(NSString *)name{
// return _name;
@end
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题
- 无题。。。
- 无题
- 无题
- 无题
- Eclipse/MyEclipse注释模板和格式化模板的使用
- eclipse调整utf8
- Info.plist Utility Error: “Info.plist couldn't be opened because there is no such file”
- Java 面试题
- 【数据结构】·【链表】·【JAVA版】
- 无题
- POJ2418 Hardwood Species(二叉搜索树+字典树+MAP)
- 分析JVM的性能利器-iotop和jstack
- leetcode-Add Digits
- HLG 1530 Pie(浮点二分)
- 开启我的博客之旅
- Java <!--随机数的产生 -->
- [LeetCode] Longest Increasing Subsequence
- Android 面试题目01