要运行示例项目,请克隆仓库,首先从 Example 目录运行 pod install
。
此示例使用基本 HTTP 身份验证获取 URL 内容,并将内容反序列化为对象
GGWs *ws=[[GGWs alloc] init];
ws.url=@"https://api.github.com/repos/greengrowapps/GGRest/commits";
ws.method=GET;
ws.authentication=[[GGHttpBasicAuth alloc] initWithUsername:@"YOUR_GITHUB_USER" andPassword:@"YOUR_GITHUB_PASSWD"];
ws.onOkArray=^(NSArray *commitsList ,GGGitCommit *nill ){
for(GGGitCommit *c in commitsList){
NSLog(@"Commit: %@",c);
}
};
ws.onError=^(GGHttpResponse *response,NSError *error){
NSLog(@"Unknown error");
};
[ws onResponse:404 objectCallBack:^(GGHttpResponse *res){
NSLog(@"Repo not found");
}];
[ws onResponse:401 objectCallBack:^(GGHttpResponse *res){
NSLog(@"Invalid credentials");
}];
[ws execute];
GGRest 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到 Podfile 中:
pod "GGRest"
GGRest 在 Apache License Version 2.0 许可下可用。有关更多信息,请参阅 LICENSE 文件。