新浪微博开放平台
https://open.weibo.com/apps
腾讯开放平台
https://open.tencent.com
社会化分享组件平台
http://sharesdk.mob.com
Bmob后端云平台
https://www.bmob.cn
一.腾讯开放平台的使用
1.准备过程
进入官网https://open.tencent.com注册成为开发者,创建应用
进入文档下载SDK
2.下载的SDK里面包含了使用文档以及demo
新增一条URL scheme
添加依赖库
添加白名单
详细内容见下载的SDK里面的指导以及demo
二.Bmob的简单使用
1.准备过程:
1.进入https://www.bmob.cn官网,注册
2.创建应用
3.获取密钥和下载SDK
4.使用-推荐使用CocoaPod安装BmobSDK
2.简单的使用以及开发文档
http://doc.bmob.cn/data/ios/#_1
3.代码例子
3.1准备
在创建的应用下面创建表
可以添加列,我们自己就添加了name和age
3.2利用CocoaPod安装BmobSDK,并在Appdelegate中配置
#import "AppDelegate.h"
#import <BmobSDK/Bmob.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[Bmob registerWithAppKey:@"1a770570e60f27bdba5b718b01b7e722"];
return YES;
}
@end
3.3插入数据
-(void)insert{
//1.找到对应的表
BmobObject *studentTable = [BmobObject objectWithClassName:@"xiaoshitou_table"];
//2.插入数据
[studentTable setObject:@"xl" forKey:@"name"];
[studentTable setObject:@20 forKey:@"age"];
//3.保存数据
[studentTable saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
if (isSuccessful) {
NSLog(@"保存成功");
}else{
NSLog(@"保存失败:%@",error);
}
}];
}
3.4查询一条数据
-(void)select{
BmobQuery *query = [BmobQuery queryWithClassName:@"xiaoshitou_table"];
//通过id号查询数据
[query getObjectInBackgroundWithId:@"1a3ca840d4" block:^(BmobObject *object, NSError *error) {
//查询结果保存在object里面
//使用objectForKey获取
NSString *name = [object objectForKey:@"name"];
NSNumber *age = [object objectForKey:@"age"];
NSDate *date = [object objectForKey:@"createdAt"];
NSLog(@"%@ %@ %@",name,age,date);
}];
}
3.5查询多条数据
-(void)selectMore{
BmobQuery *query = [BmobQuery queryWithClassName:@"xiaoshitou_table"];
//设置查找限制
query.limit = 3;
[query findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {
for (BmobObject *object in array) {
NSString *name = [object objectForKey:@"name"];
NSNumber *age = [object objectForKey:@"age"];
NSDate *date = [object objectForKey:@"createdAt"];
NSLog(@"%@ %@ %@",name,age,date);
}
}];
}
3.6更多的操作参考官方文档
网友评论