LYCore 1.13.2

LYCore 1.13.2

blodely 维护。



 
依赖项
AFNetworking~> 4.0
FCFileManager~> 1.0.20
LYCategory~> 1.12
Masonry~> 1.1.0
JLRoutes~> 2.1
 

LYCore 1.13.2

LYCore

适用于应用程序的通用核心库。

如何使用

简单添加 pod 'LYCore',然后运行 'pod install'。

配置网络环境

复制 space.luoyu.core.conf.plist 配置模板的一份副本,并将其添加到您的项目中。

值示例
(更改为您自己的服务器设置)
备注
core-net-domain app.luoyu.space 核心网络域名(生产)
core-net-domain-dev dev.luoyu.space 核心网络域名(开发)
core-net-api-path /api 核心网络 API 路径(生产)
core-net-api-path-dev /api-v2 核心网络 API 路径(开发)
core-net-is-secure-transport https:// 传输安全开关(生产)
core-net-is-secure-transport-dev http:// 传输安全开关(开发)

通过切换 [LYCore core].debug (BOOL),库将使用相应的值生成会话管理器。

示例

# production mode
https://app.luoyu.space/api

# development mode
http://dev.luoyu.space/api-v2
您可以根据自己的需要添加自己的键值配置

并通过以下方式访问...

// get configuration data (NSDictionary object)
[[LYCore core] conf];

或者

// get value for key
[[LYCore core] valueForConfWithKey:@"the-key-name"];

自定义请求

只需将类别添加到LYCoreAPI中,然后您就可以编写自己的指定请求方法。

示例

LYCoreAPI+Example.h

#import <LYCore/LYCore.h>

@interface LYCoreAPI (Example)

- (NSURLSessionDataTask *)GETURLString:(NSString *)URLString
	withParameters:(NSDictionary *)params
	success:(void (^)(id ret))success
	error:(void (^)(NSInteger code, NSString *msg, id ret))apierror
	failure:(void (^)(NSError *error))failure;

@end

此文件添加了一个api错误代码块以处理项目错误代码。

LYCoreAPI+Example.m

#import "LYCoreAPI+Example.h"

@implementation LYCoreAPI (Example)
- (NSURLSessionDataTask *)GETURLString:(NSString *)URLString withParameters:(NSDictionary *)params success:(void (^)(id))success error:(void (^)(NSInteger, NSString *, id))apierror failure:(void (^)(NSError *))failure {
    NSURLSessionDataTask *datatask = [self GETURLString:URLString withParameters:params success:^(id ret) {
        if (ret == nil) {
            apierror(1, @"NULL RESPONSE", ret);
        } else {
            success(ret);
        }
    } failure:^(NSError *error) {
        failure(error);
    }];
    return datatask;
}
@end

定位

从1.0.31版本开始,核心库现在可以支持使用CoreLocation来获取当前位置标记。

用法

[[LYApp current] updateLocation:^(CLLocationCoordinate2D coordinate, CLPlacemark *place) {
	// IF 'place' IS NOT NIL,
	// MEANS SUCCESSFULLY GET CURRENT LOCATION PLACEMARK.
	NSLog("%@", place);
}];

作者

骆昱(Luo Yu)

Email: [email protected]

Date: 星期二,2018年4月17日