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]

实时搜索用户列表             

使用搜索API非常灵活。在下面的示例中,Search用于通过Material的SearchBar提供的动态UI创建对用户名的实时搜索。

Preparing the search criteria

let graph = Graph()
 
let search = Search<Entity>(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
}
人工智能芯片与自动驾驶
原文地址:https://www.cnblogs.com/wujianming-110117/p/14193781.html