MIT Graph实践概述
MIT Graph實踐概述
Features功能
? iCloud Support
? Multi Local & Cloud Graphs
? Thread Safe
? Store Any Data Type, Including Binary Data
? Relationship Modeling
? Action Modeling For Analytics
? Model With Graph Theory and Set Theory
? Asynchronous / Synchronous Search
? Asynchronous / Synchronous Saving
? Data-Driven Architecture
? Data Model Observation
? Comprehensive Unit Test Coverage
? Example Projects
Requirements
? iOS 8.0+ / Mac OS X 10.10+
? Xcode 8.0+
Communication
如果需要幫助,請使用堆棧溢出。(標簽“cosmicmind”)
如果想問一個一般性問題,使用堆棧溢出。
如果發現了一個bug,并且能夠提供可靠地復制它的步驟,那么就說出一個問題。
如果有功能請求,說出問題。
如果想投稿,提交一個請求。
Installation安裝
Embedded frameworks require a minimum deployment target of iOS 8.
https://github.com/CosmicMind/Graph
CocoaPods
CocoaPods是Cocoa項目的依賴關系管理器。可以使用以下命令進行安裝:
$ gem install cocoapods
要使用CocoaPods將Graph的核心功能集成到Xcode項目中,在Podfile中指定它:
source ‘https://github.com/CocoaPods/Specs.git’
platform :ios, ‘8.0’
use_frameworks!
pod ‘Graph’, ‘~> 3.1.0’
然后,運行以下命令:
$ pod install
Carthage
Carthage是一個分散的依賴關系管理器,構建依賴關系并提供二進制框架。 可以使用以下命令自制軟件安裝基:
$ brew update
$ brew install carthage
要使用Carthage將Graph集成到Xcode項目中,請在Cartfile中指定:
github “CosmicMind/Graph”
運行carthage update來構建框架并拖動構建的圖形框架你的Xcode項目。 變更日志
Graph是一個不斷發展的項目,在整個開發過程中都會遇到變化。建議在更新版本之前查看變更日志。
樣品
下面是一些示例,以了解如何在應用程序中使用Graph。
訪問示例repo以查看使用圖形的示例項目。
為圖像卡創建實體
實體是一個模型(數據)對象,它代表一個人、一個位置或一件事。它可以存儲屬性值,組的成員,并且可以被標記。
在下面的示例中,使用Material創建一個ImageCard視圖,并用一個實體填充它的屬性,該實體存儲該視圖的數據。
Creating data
let graph = Graph()
let entity = Entity(type: “ImageCard”)
entity[“title”] = “Graph”
entity[“detail”] = “Build Data-Driven Software”
entity[“content”] = “Graph is a semantic database that is used to create data-driven applications.”
entity[“author”] = “CosmicMind”
entity[“image”] = UIImage.load(contentsOfFile: “frontier”, ofType: “jpg”)
graph.sync()
Setting the view’s properties
imageCard.toolbar?.title = entity[“title”] as? String
imageCard.toolbar?.detail = entity[“detail”] as? String
imageCard.imageView?.image = entity[“image”] as? UIImage
let contentLabel = UILabel()
contentLabel.text = entity[“content”] as? String
imageCard.contentView = contentLabel
let authorLabel = UILabel()
authorLabel.text = entity[“author”] as? String
imageCard.bottomBar?.centerViews = [authorLabel]
? Download the complete ImageCard example.
? Learn more about Material’s ImageCard.
實時搜索用戶列表
使用搜索API非常靈活。在下面的示例中,Search用于通過Material的SearchBar提供的動態UI創建對用戶名的實時搜索。
Preparing the search criteria
let graph = Graph()
let search = Search(graph: graph).for(types: “User”).where(properties: “name”)
Asynchronously searching graph
search.async { [weak self, pattern = pattern] (users) in
guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {return
}var data = [Entity]()for user in users {if let name = user["name"] as? String {let matches = regex.matches(in: name, range: NSRange(location: 0, length: name.utf16.count))if 0 < matches.count {data.append(user)}}
}self?.tableView.data = data
}
? Download the complete Search example.
? Learn more about Material’s SearchBar.
總結
以上是生活随笔為你收集整理的MIT Graph实践概述的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编写HSA内核
- 下一篇: nvGraph-NVIDIA图形库