I osアプリのmvcモデル
- 2. MVCとは
• Model
- Viewを構成する情報を保持する
• View
- Modelのデータを表示する
- ユーザから操作を受ける
• Controller
- Modelに情報の更新を命令する
- ViewにModelの情報を送り、Viewを通じて
ユーザからの操作を受ける
✦プログラムを以下三つのカテゴリに分けてクラ
ス設計するデザインパターン
13年7月3日水曜日
- 11. Entityクラスによる情報管理
• こんなJSONがあった場合
[
{
"id" : "1FZ3P4ACUWBBC-2010061010321",
"created_at" : "Thu Jun 10 01:32:13 +0000 2010",
"text" : "つぶやきの本文",
"user" : {
"id" : "1FZ3P4ACUWBB",
"screen_name" : "Becky",
"profile_image_url" : "http://profile.img.xxxxxx.jpg",
"url" : "http://ssteaete/show_friend.pl?uid=1FZ3P4ACUWBB"
},
"reply_count" : "3",
"favorite_count" : "5",
"favorited" : true
},
・・・
]
13年7月3日水曜日
- 12. ベタなNSArrayで管理せずに専用のDictionaryオブ
ジェクトクラスを作る
#import <Foundation/Foundation.h>
@interface SAMUserEntity : NSObject
@property (nonatomic, strong) NSString *profileImageURL;
@property (nonatomic, strong) NSString *URL;
@property (nonatomic, strong) NSString *userID;
@property (nonatomic, strong) NSString *screenName;
+(MixiUserEntity *)userEntitiWithDict:(NSDictionary *)dict;
@end
@interface SAMVoiceEntity : NSObject
@property (nonatomic, strong) NSString *voiceID;
@property (nonatomic, strong) NSString *createdAt;
@property (nonatomic, strong) NSString *text;
@property (nonatomic, assign) NSInteger replyCount;
@property (nonatomic, assign) NSInteger favoriteCount;
@property (nonatomic, assign) BOOL favorited;
@property (nonatomic, strong) SAMUserEntity *userEntity;
+(MixiVoiceEntity *)voiceEntitiWithDict:(NSDictionary *)dict;
@end
13年7月3日水曜日