• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ipfs-shipyard/swift-ipfs-http-client: A Swift client library for the IPFS HTTP A ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ipfs-shipyard/swift-ipfs-http-client

开源软件地址:

https://github.com/ipfs-shipyard/swift-ipfs-http-client

开源编程语言:

Swift 99.6%

开源软件介绍:

swift-ipfs-api

standard-readme compliant

A Swift client library for the IPFS API.

For more information about IPFS or the API commands click the links.

The Swift IPFS API shell/client is an asynchronous library that provides native calls to an IPFS node.

Table of Contents

Install

In the root of your project:

  • Add a Cartfile (or use an existing one) with the following:
github "ipfs/swift-ipfs-api" "master"
  • To fetch and build the dependencies, type:

carthage update --platform Mac

or

carthage update --platform iOS

or

carthage update

if you want both platforms.

For more information on how to install via Carthage see the README

Usage

Add the required frameworks to your project in Xcode:

  • In your target's build phases tab.

  • Click the + in the upper left corner and pick the New Copy Files Phase from the drop-down.

  • Select the Destination Frameworks and click the + to Add Other... buttons.

  • Navigate to the Carthage/Build/Mac directory in your project root and select all the frameworks in the folder.

Examples

In your code:

import SwiftIpfsApi

do {
  let api = try IpfsApi(host: "127.0.0.1", port: 5001)

  try api.id() { (idData : JsonType) in
    guard let id = idData.object?["ID"]?.string else {
      return
    }
    print("Yay, I've got an id: \(id)")
  }
} catch {
  print(error.localizedDescription)
}

The Swift IPFS API client is asynchronous, but if you want to use a command synchronously (eg. if you run it in its own thread) you can always use dispatch groups:

let group = dispatch_group_create()
dispatch_group_enter(group)

let multihash = try! fromB58String("QmXsnbVWHNnLk3QGfzGCMy1J9GReWN7crPvY1DKmFdyypK") 

try! api.refs(multihash, recursive: false) {
    result in
    for mh in result {
        print(b58String(mh))
    }
    
    dispatch_group_leave(group)
}

dispatch_group_wait(group, DISPATCH_TIME_FOREVER)

Requirements

Swift 3

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ipfs/camp: 发布时间:2022-06-23
下一篇:
liyuechun/ipfs_blogger: 【IPFS + 区块链 系列】 入门篇 - IPFS+IPNS+个人博客搭建 ...发布时间:2022-06-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap