Skip to content

Commit

Permalink
更新 MinCloud API
Browse files Browse the repository at this point in the history
  • Loading branch information
pqhifanr committed Oct 31, 2019
1 parent 9c785cf commit a0ba2b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions swiftui-tutorial/Daily-Part1-finished/Daily/DaliyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ final class DaliyStore: ObservableObject {
var _newsList: [News] = []
recordList?.records?.forEach({ (record) in
let id = record.Id
let title = record.get(key: "title") as? String
let author = record.get(key: "author") as? String
let date = record.get(key: "date") as? String
let content = record.get(key: "content") as? String
let thumbnail = record.get(key: "thumbnail") as? String
let title = record.get("title") as? String
let author = record.get("author") as? String
let date = record.get("date") as? String
let content = record.get("content") as? String
let thumbnail = record.get("thumbnail") as? String
if let id = id, let title = title, let author = author, let date = date, let content = content, let thumbnail = thumbnail {
let news = News(id: id, title: title, author: author, date: date, content: content, thumbnail: thumbnail)
_newsList.append(news)
Expand Down
14 changes: 7 additions & 7 deletions swiftui-tutorial/Daily-Part1-finished/Daily/News.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ struct News: Identifiable {
}

func fetchDaliy() -> [News] {

let newsDicts = [["id": "0", "title": "60 天打印一枚火箭", "author": "ifanr", "content": "今年 4 月,SpaceX 重型猎鹰完成首次商业发射", "date": "10-15", "thumbnail": "https://s3.ifanr.com/wp-content/uploads/2019/10/Launch_OffPad.4k.0.jpg!720"],
["id": "1", "title": "当你在看电视的时候,电视也在看你", "author": "ifanr", "content": "智能电视广告的问题着实让人心烦。", "date": "10-15", "thumbnail": "https://s3.ifanr.com/wp-content/uploads/2019/10/qtfy.jpg!720"]]

var newsList: [News] = []
let daliyPath: String = Bundle.main.path(forResource: "daliy", ofType:"plist")!
let daliy: NSArray = NSArray(contentsOfFile: daliyPath) ?? []
for (index, newsDict) in daliy.enumerated() {
if let newsDict = newsDict as? [String: Any] {
let news = News(id: String(index), title: newsDict["title"] as! String, author: newsDict["author"] as! String, date: newsDict["date"] as! String, content: newsDict["content"] as! String, thumbnail: newsDict["thumbnail"] as! String)
newsList.append(news)
}
for newsDict in newsDicts {
let news = News(id: newsDict["id"]!, title: newsDict["title"]!, author: newsDict["author"]!, date: newsDict["date"]!, content: newsDict["content"]!, thumbnail: newsDict["thumbnail"]!)
newsList.append(news)
}

return newsList
Expand Down
10 changes: 5 additions & 5 deletions swiftui-tutorial/Daily-Part2-finished/Daily/DaliyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ final class DaliyStore: ObservableObject {
var _newsList: [News] = []
recordList?.records?.forEach({ (record) in
let id = record.Id
let title = record.get(key: "title") as? String
let author = record.get(key: "author") as? String
let date = record.get(key: "date") as? String
let content = record.get(key: "content") as? String
let thumbnail = record.get(key: "thumbnail") as? String
let title = record.get("title") as? String
let author = record.get("author") as? String
let date = record.get("date") as? String
let content = record.get("content") as? String
let thumbnail = record.get("thumbnail") as? String
if let id = id, let title = title, let author = author, let date = date, let content = content, let thumbnail = thumbnail {
let news = News(id: id, title: title, author: author, date: date, content: content, thumbnail: thumbnail)
_newsList.append(news)
Expand Down

0 comments on commit a0ba2b0

Please sign in to comment.