YIem`s Blog -心比天高命比纸薄-链接找不到的请在站内搜索内容!

2015-12-24-// 目标: 数组+字典 -> 数组 + model对象

//
// AppDelegate.h
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end


//
// AppDelegate.m
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "AppDelegate.h"

import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

@end



//
// ViewController.h
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@end


//
// ViewController.m
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "ViewController.h"

import "MovieCell.h"

import "SecondViewController.h"

import "MovieModel.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate, PassDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSMutableArray *dataArr;
@end

@implementation ViewController

// cell.pubLabel.text = dic[@"pubdate"];
// cell.titleLabel.text = dic[@"title"];


// KVC赋值之后 cell的值
MovieModel *m = _dataArr[indexPath.row];
cell.titleLabel.text = m.title;
// cell.titleLabel.text = xx
cell.pubLabel.text = m.pubdate;


// 多态  ->子类指针 指向父类对象
// 子类对象的不同 可以呈现不同的结果

// NSObject *a = [[UITableViewCell alloc]init];
// NSObject *b = [[MovieCell alloc] init];




 return cell;

}

@end



//
// MovieCell.h
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface MovieCell : UITableViewCell
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *pubLabel;
@end


//
// MovieCell.m
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "MovieCell.h"

@implementation MovieCell

@end



//
// SecondViewController.h
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@protocol PassDelegate <NSObject>

@end
@interface SecondViewController : UIViewController
@property (nonatomic, retain) NSDictionary *receiveValue;
@property (nonatomic, assign) id<PassDelegate>delegate;
@end


//
// SecondViewController.m
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

}

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

*/

@end



//
// MovieModel.h
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <Foundation/Foundation.h>

@interface MovieModel : NSObject

warning 使用KVC赋值的model类中 定义的属性名 一定要和字典中的key值相同(一般情况下) 数据类型也要保证一致

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *pubdate;
@property (nonatomic, retain) NSNumber *wish;
@property (nonatomic, copy) NSString *movieid;
@end


//
// MovieModel.m
// UI11_练习2
//
// Created by YIem on 15/12/21.
// Copyright © 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "MovieModel.h"

@implementation MovieModel

// KVC容错方法(赋值)

// KVC容错方法(取值)
/*

*/

@end

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »