IOS开发之微博的设计与实现
2015-07-20 08:23
489 查看
// // main.m // Microblog // #import <Foundation/Foundation.h> #import "Person.h" #import "BlogMaster.h" #import "Microblog.h" int main(int argc, const char * argv[]) { Person * person = [[Person alloc]init]; [person showName]; NSLog(@"%@",person); Person * man = [[Person alloc]init]; [man showName]; //Microblog * microblog = [[Microblog alloc]init]; return 0; }
#import <Foundation/Foundation.h> @interface Person : NSObject { /**用来记录人的名字*/ NSString * _name; /**用来记录人的年龄*/ int _age; /**用来记录出生年月*/ NSString * _birthday; /**用来记录性别*/ char _sex; /**用来记录所在地*/ NSString * _address; /**用来记录感情状况*/ NSString * _emotion; /**用来记录血型*/ NSString * _bloodType; } @property NSString * name; @property int age; @property NSString * birthday; @property char sex; @property NSString * address; @property NSString * emtion; @property NSString * bloodType; -(void)showName; @end
#import "Person.h" #import <Foundation/Foundation.h> @implementation Person -(void)showName { NSLog(@"打印人的名字"); //NSLog(@"%@",_name); } -(NSString *)description { return [NSString stringWithFormat:@"名字=%@ 年龄=%d 出生日期=%@性别=%c 住址=%@ 感情状况=%@ 血型=%@",_name,_age,_birthday,_sex,_address,_emotion,_bloodType]; } @end
#import <Foundation/Foundation.h> #import "BlogMaster.h" #import "Person.h" @interface Microblog : NSObject { /**用来存储博主信息*/ //BlogMaster * _blogMaster; /**用来存储注册时间*/ NSString * _registerTime; /**简介*/ NSString * _introductionAboutBlog; /**用来记录博客内容*/ NSString * _blogContent; /**用来记录评论内容*/ NSString * _commentContent; /**用来记录评论数量*/ int _commentAmount; /**用来记录点赞数量*/ int _praiseAmount; /**用来记录微博发表时间*/ NSString * _publishTime; /**用来记录转发数量*/ int _transpond; } @property NSString * registerTime; @property NSString * introductionAboutBlog; @property NSString * blogContent; @property NSString * commentContent; @property NSString * publishTime; @property int commentAmount; @property int praiseAmount; @property int transpond; //-(void)printBlogMasterName:(Person *)person; @end
#import "Microblog.h" @implementation Microblog //-(void)printBlogMasterName:(Person *)person //{ // if([Person isKindOfClass:[BlogMaster class]]) // { // BlogMaster * master = (BlogMaster *)person; // } // [master showName]; //} -(NSString *)description { return [NSString stringWithFormat:@" 博客内容=%@ 评论数量=%d 点赞数量=%d 发表时间=%@ 转发数量=%d",_blogContent,_commentAmount,_praiseAmount,_publishTime,_transpond]; } @end
#import "Person.h" @interface BlogMaster : Person { } -(void)showName; @end
#import "BlogMaster.h" @implementation BlogMaster -(void)showName { NSLog(@"博主的名字"); } @end
相关文章推荐
- IOS计算器的实现
- iOS动画之倒影
- iOS动画之粒子效果
- 快速安装cocoaPods的教程,利用cocoaPods对IOS程序进行依赖管理
- iOS动画之活动指示器
- IOS开发常见命名规范:
- 移动游戏开发,你所不知道的秘密!
- 快速掌握iOS 开发的技巧和方法
- 免费公开课福利来了
- ios摇一摇截屏代码
- 我的BIOS之行(3)-遍历pci设备(1)io访问
- 去除iOS 6程序图标的玻璃质感效果
- 在ios中举个简单的protocol例子,关于两个类用协议方式传值。
- iOS 重写 isequal方法需重写hash方法
- iOS中nil 、NULL、 Nil 、NSNull的区别详谈
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记37 TableView Delegate
- IOS应用
- 一个猜数字输赢的小游戏
- iOS初学者第四天
- iOS 字符串读写