iOS学习- 10 定义数据模型及构造本地运行时数据 - Todo App
来源:互联网 发布:mac svn 管理工具下载 编辑:程序博客网 时间:2024/05/16 12:46
1.) Adding a Model for Table view
code:
//
// TodoModel.swift
// Todo
//
// Created by Ricky Choi on 16/6/2.
// Copyright © 2016年 worm. All rights reserved.
//
import UIKit
class TodoModel: NSObject {
var id: String
var image: String
var title: String
var date: NSDate
init (id: String, image: String, title: String, date: NSDate) {
self.id = id
self.image = image
self.title = title
self.date = date
}
}
2.) contructor the running time data list
//
// ViewController.swift
// Todo
//
// Created by Ricky Choi on 16/6/1.
// Copyright © 2016年 worm. All rights reserved.
//
import UIKit
var todos: [TodoModel] = []
func dateFromString(dateStr: String) -> NSDate? {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyy-MM-dd"
let date = dateFormatter.dateFromString(dateStr)
return date
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
todos = [TodoModel(id: "1", image: "child-selected", title: "1. 去游乐场", date: dateFromString("2014-11-2")!),
TodoModel(id: "2", image: "shopping-cart-selected", title: "2. ", date: dateFromString("2014-10-28")!),
TodoModel(id: "3", image: "phone-selected", title: "3. 打电话", date: dateFromString("2014-10-30")!),
TodoModel(id: "4", image: "travel-selected", title: "4. Travel to Europe", date: dateFromString("2014-10-31")!),
]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
- iOS学习- 10 定义数据模型及构造本地运行时数据 - Todo App
- iOS学习- 09 控件 UITableViewController - Todo App
- iOS学习- 12 绑定数组数据到Table View - Todo App
- IOS定义数据模型类
- iOS学习- 11 TableView 显示TableViewCell 显示 - Todo App
- iOS学习- 13 删除Table View中的Cell - Todo App
- iOS学习- 14 增加Table View中的iteml - Todo App
- iOS学习- 14 adding tableview item logic - Todo App
- iOS学习- 15 Edit tableview item - Todo App
- iOS学习- 15 Move tableview item - Todo App
- iOS学习- 16 search tableview item - Todo App
- iOS APP之本地数据存储
- iOS APP 本地数据存储和缓存
- iOS 本地缓存 归档数据模型化
- iOS 本地缓存 归档数据模型化 .m
- iOS/Android 浏览器(h5)及微信中唤起本地APP
- iOS/Android 浏览器(h5)及微信中唤起本地APP
- iOS/Android 浏览器(h5)及微信中唤起本地APP
- 关于centos 执行yum -y install xxx报错Could not retrieve mirrorlist http://mirrorlist.centos.org/?
- android 对线程池的探究
- 让html标签显示在页面上
- Python核心编程(第十三章)--面向对象编程
- Gradle学习系列之八——构建多个Project
- iOS学习- 10 定义数据模型及构造本地运行时数据 - Todo App
- Count and Say (java)
- Jenkins的部署及使用教程(插件集成sonar服务,构建过程做代码分析)
- Gradle学习系列之九——自定义Task类型
- 向maven仓库中手动安装本地jar的三种方法
- Sonar 使用详解
- iOS 基础篇8—从代码的逐步优化看MVC
- md5
- C++中ifstream使用笔记(一)(常用方法和注意事项)