IOS开发之微博的设计与实现
2023-09-27 14:27:00 时间
// // 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开发 - 不进入待机(屏幕保持唤醒)---UIApplication学习
- iOS开发系列--UITableView全面解析
- ios怎样实现快速将显卡中数据读出压缩成视频在cocos2dx扩展开发中
- 猫猫学iOS 之微博项目实战(2)微博主框架-自己定义导航控制器NavigationController
- iOS开发如何提高(from 唐巧的博客)
- IOS委托设计模式(摘自IOS开发指南)
- iOS后台如何保持socket长连接和数据传输
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- iOS开发 适配iOS10
- iOS 苹果开发证书失效的解决方案(Failed to locate or generate matching signing assets)
- iOS中 iOS10 权限崩溃问题 韩俊强的CSDN博客
- 通知模式实现两个textField传值及模态视图——iOS开发
- iOS中怎样加入自己定义的字体
- iOS_17_控制开关_TabBarController_由storyboard道路
- iOS开发--APP性能检测方案汇总(一)
- iOS开发之记录用户登录状态
- 李洪强漫谈iOS开发[C语言-048]-打印平方表
- 在MacOS和iOS系统中使用OpenCV
- 李洪强iOS开发之录音和播放实现
- iOS开发UI篇—CALayer简介
- iOS开发UI篇—实现UItableview控件数据刷新
- 李洪强漫谈iOS开发[C语言-020]-scanf的本质
- 李洪强iOS开发之OC[012] -类的声明实现小结
- 李洪强iOS开发之OC[011] - 有参方法的声明实现以及调用练习
- 李洪强iOS开发之OC[010] - 有参方法的声明实现和调用
- 李洪强iOS开发之OC[007] - 李洪强iOS开发之类的声明和实现
- 苹果官方文档:理解和分析ios应用崩溃日志