object-c模型设计练习
来源:互联网 发布:国外保健品网络销售 编辑:程序博客网 时间:2024/06/05 07:59
设计模型:
微博用户包含:
姓名、微博号码、密码、头像、性别、手机、生日
微博包含:微博内容、微博配图、发送时间、微博发送人、转发的微博、被评论数、被转发数
User.h
#import <Foundation/Foundation.h>typedef enum { SexMan, //男 SexWomen //女}Sex;typedef struct { int year; int month; int day;}Date;// 姓名、微博号码、密码、头像、性别、手机、生日@interface User : NSObject@property (nonatomic, retain) NSString *name;@property (nonatomic, retain) NSString *account;@property (nonatomic, retain) NSString *password;//http://weibo.com/a.png - URL@property (nonatomic, retain) NSString *icon;@property (nonatomic, assign) Sex sex;@property (nonatomic, retain) NSString *phone;@property (nonatomic, assign) Date date;@end
User.m
#import "User.h"@implementation User- (void)dealloc{ [_name release]; [_account release]; [_password release]; [_icon release]; [_phone release]; [super dealloc];}@end
Status.h
#import <Foundation/Foundation.h>#import "User.h"// 微博内容、微博配图、发送时间、微博发送人、转发的微博、被评论数、被转发数@interface Status : NSObject@property (nonatomic, retain) NSString *text;@property (nonatomic, retain) NSString *icon;// 从1970-01-01 00:00:00 开始,一共度过的多少毫秒(time_t = long)@property (nonatomic, assign) time_t time;@property (nonatomic, retain) User *user;@property (nonatomic, retain) Status *retweetStatus;@property (nonatomic, assign) int commentsCount;@property (nonatomic, assign) int retweetsCount;@end
Status.m
#import "Status.h"@implementation Status- (void)dealloc{ [_text release]; [_icon release]; [_user release]; [_retweetStatus release]; [super dealloc];}@endmain.m
#import <Foundation/Foundation.h>#import "User.h"#import "Status.h"int main(int argc, const char * argv[]){ // 新建2个用户 User *u = [[User alloc] init]; u.name = @"2B"; User *u2 = [[User alloc] init]; u2.name = @"傻B"; // 新建2条微博 Status *s = [[Status alloc] init]; s.text = @"今天天气真好!"; s.user = u; Status *s2 = [[Status alloc] init]; s2.text = @"今天天气真的很好!"; s2.retweetStatus = s; s2.user = u2; [u release]; [u2 release]; [s release]; [s2 release]; return 0;}
0 0
- object-c模型设计练习
- Object-C 练习
- Object-C 设计模式
- XCode4.2中练习Object-C
- object-c 代码练习第六/七天
- Object-C练习小程序(1)
- Object-C练习小程序(2)
- object-C练习小程序(3)
- object-C练习小程序(4)
- object-C练习小程序(5)
- Object-C delegate 设计模式
- object c 工厂设计模式
- C-二级指针输出模型练习
- Objective-C - 模型的设计
- Object-c的单例设计
- Object-C memory manager 练习与结果分析
- Object-C学习 属性、点语法练习
- IOS开发---OC语言-㉒@property模型设计练习
- Window7通过samba服务共享虚拟机中Linux的目录
- new和malloc的区别
- Your content must have a ListView whose id attribute is 'android.R.id.list' 解决方法
- 内容提供者复习——短信备份
- CentOS系统安全配置指南
- object-c模型设计练习
- 你单方面能开机能看到你发了可能浪费的理念
- 11.2 DL动态加载框架、隐藏自己应用图标
- Volley本地缓存为什么有时候不会进行缓存?
- 模板方法模式
- java基础之抽象和接口
- Eclipse Building workspace.GC overhead limit exceeded 解决方法
- Ubuntu 下Software center的默认安装路径
- 实战中遇到的C++流文件重置的一个大陷阱: 为什么ifstream的seekg函数无效?