LeanCloud SDK 封装 LeanMotion

码农软件 · 软件分类 · 网站API · 2019-03-09 16:11:43

软件介绍

LeanCloud ,一个为移动应用提供数据统计、数据存储、消息推送、发送短信、发送邮件等云服务商。

LeanMotion 是一个RubyMotion的Gem,可以更加方便地使用LeanCloud SDK。
用更Ruby的写法来操作LeanCloud的数据,类Rails的ActiveRecord,增删查改。

安装说明

1、安装gem

gem install lean_motion

2、创建项目

lean_motion create app-name

3、修改 app_delegate.rb
设置LeanCloud的App ID和App Key

app_id   = "your_app_id"
app_key  = "your_app_key"

4、运行

rake

使用说明

1、在LeanCloud后台创建一个Class,比如Product,并添加以下字段

name: String
description: String
url: String

2、添加model文件 product.rb,建议放在app/models/目录下

class Product
  include LM::Model

  fields :name, :description, :url
end

3、操作数据

新建产品

product = Product.new
product.name        = 'iPhone 6'
product.description = '目前最好的智能手机'
product.url         = 'http://www.apple.com'
product.save

产品数量

Product.count

查询产品

Product.where(:name=>'iPhone 6').find

获得第一条记录

Product.first

排序

Product.sort(:createdAt=>:desc).find

分页(默认是20条记录/页)

Product.page(current_page, pagesize)

4、帐号相关 注册帐号

user = User.new
user.username = '用户名,必须唯一'
user.password = '必填'
user.signUp

登录

User.login('用户名', '密码') do |user, error|
  if !error
    p '登录成功'
  end
end

退出

User.logout

判断是否已登录

User.login?
end

判断用户是否已存在

User.exist? username

本文地址:https://www.codercto.com/soft/d/978.html

个体与交互

个体与交互

Ken Howard、Barry Rogers / 贾永娜、张凯峰 / 机械工业出版社华章公司 / 2012-3-20 / 45.00元

对敏捷软件开发的关注重点,通常都集中在“机制”方面,即过程和工具。“敏捷宣言”认为,个体与交互的价值要高于过程和工具,但这一点很容易被遗忘。在敏捷开发中,如果你重新将注意力放在人的方面,将会收获巨大利益。 本书展示了如何解决敏捷团队在实际项目中遭遇的问题。同时,本书也是很有实用价值的敏捷用户指南,其中包含的故事、最佳实践方法、经验以及技巧均可应用到实际项目当中。通过逐步实践,你将学会如何让团......一起来看看 《个体与交互》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具