KVC的步骤 以及重点
来源:互联网 发布:小米手环抢购软件 编辑:程序博客网 时间:2024/06/05 22:45
MVC的步骤 以及重点
Contriller.m
#import "MusickPlayTableController.h"
#import "MusickListCell.h"
#import "MusickModel.h"
@interface MusickPlayTableController ()
@property(nonatomic,retain)NSArray*dataArray;
@property(nonatomic,retain) NSMutableArray *musicArray;
@end
@implementation MusickPlayTableController
- (void)viewDidLoad {
[super viewDidLoad];
self.title=@"听风";
NSURL*url = [NSURL URLWithString:@"http:project.lanou3g.com/teacher/UIAPI/MusicInfoList.plist"];
NSURLRequest*ruquest = [NSURLRequest requestWithURL:url cachePolicy:0 timeoutInterval:5.0];
//网络请求
[NSURLConnection sendAsynchronousRequest:ruquest queue:[[NSOperationQueue alloc ]init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (connectionError) {
NSLog(@"错误 %@",connectionError);
return ;
}
//data 是一个plisst 数据,对data进行 反序列化解写
_dataArray=[NSPropertyListSerialization propertyListWithData:data options:0 format:NULL error:NULL];
_musicArray = [NSMutableArray array];
for (NSDictionary * dic in _dataArray) {
NSLog(@"%@",dic);
MusickModel*model=[[MusickModel alloc] init];
[model setValuesForKeysWithDictionary:dic]; //必须写 否则赋不上值
[_musicArray addObject:model]; //必须写 否则赋不上值
// NSLog(@"%@",model.singer);
}
[self.tableView reloadData];
//从新加载
// [self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
// //.....
});
}];
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
View.m
#import "MusickListCell.h"
@implementation MusickListCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self =[ super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
//歌曲名
CGRect rect1=CGRectMake(180, 20, 200, 40);
_SongNameLabel=[[UILabel alloc] initWithFrame:rect1];
_SongNameLabel.backgroundColor=[UIColor redColor];
[self addSubview:_SongNameLabel];
//歌者名
CGRect rect2=CGRectMake(180, 70, 200, 40);
_SingerNameLabel=[[UILabel alloc] initWithFrame:rect2];
_SingerNameLabel.backgroundColor=[UIColor greenColor];
[self addSubview: _SingerNameLabel];
//歌手头像
CGRect rect3=CGRectMake(0, 0, 100, 200);
_SingerPhtoto=[[UIImageView alloc] initWithFrame:rect3];
_SingerPhtoto.backgroundColor=[UIColor yellowColor];
[self addSubview:_SingerPhtoto];
}
return self;
}
#pragma 数据模型赋值方法
-(void)setMusickMoudel:(MusickModel *)musickMoudel
{
if (_musickMoudel!=musickMoudel) {
// _musickMoudel=[musickMoudel retain];
_SingerNameLabel.text=musickMoudel.artists_name;
_SongNameLabel.text=musickMoudel.name;
_SingerPhtoto.image =musickMoudel.picUrl;
}
}
- (void)awakeFromNib {
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end
/////////////////////////////////////////////////////////////
mosel.m
#import "MusickModel.h"
@implementation MusickModel
-(void)setValue:(id)value forKey:(NSString *)key
{
//父类方法 必须写 否则赋不上值
[super setValue:value forKey:key];
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
//防止蹦亏
}
@end
- KVC的步骤 以及重点
- CSocket以及winsocket套接字的使用步骤(网络通信的重点知识)
- KVC/KVO 的使用以及实现原理
- 煤矿物联网建设的重点及步骤
- mahout k-means聚类的入门操作步骤重点:
- IOS开发中的kvo以及kvc的理解
- HUD指示器跳出的问题以及KVC和KVO
- Git的步骤以及命令
- 关于 KVO 和 KVC 的一些总结 以及使用KVC进行字典和模型的互相转换
- Proxool :重点以及适合
- struts1和struts2的比较,以及struts2的重点介绍
- 机器学习重点与步骤
- Fragment实战重点内容以及注意的一些细节
- 划重点---Hive的shell命令以及HQL
- 谈KVC、KVO(重点观察者模式)机制编程
- 谈KVC、KVO(重点观察者模式)机制编程
- 键值编码(KVC)-简单的KVC
- kvc机制与kvc的常用方法
- HDU 5035 Delivery (2014年北京赛区网络赛D题)
- 第三方应用分享到微信朋友圈功能
- parseInt() 和强制转换的区别(int)
- xml的增,删,改,查
- hdu 1551 Cable master(二分法)
- KVC的步骤 以及重点
- UC/OS II 任务管理(2)之就绪表和就绪组
- Codeforces Gym 100340C ePig 模拟
- 登陆界面的数据处理(一)
- Leetcode229 Majority Element II
- expect
- c#使用itextsharp输出pdf(动态填充表单内容,显示中文)
- mysql 事务 与 数据库引擎
- 域传送漏洞总结