Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blodely/lycore
general core lib for apps.
https://github.com/blodely/lycore
ios objective-c pod
Last synced: about 1 month ago
JSON representation
general core lib for apps.
- Host: GitHub
- URL: https://github.com/blodely/lycore
- Owner: blodely
- License: mit
- Created: 2018-04-17T02:35:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-11T14:39:53.000Z (about 3 years ago)
- Last Synced: 2024-12-11T23:47:55.794Z (2 months ago)
- Topics: ios, objective-c, pod
- Language: Objective-C
- Size: 289 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# LYCore
General core lib for apps.
### How to use:
Simply add`pod 'LYCore'`, then run 'pod install'.
#### configure networking env
make a copy of `space.luoyu.core.conf.plist` configuration template, and add it to your project.
Key|Value example
(_change to your own server settings_)|Remark
---|:---|---
core-net-domain|app.luoyu.space|Core Networking Domain(Production)
core-net-domain-dev|dev.luoyu.space|Core Networking Domain(Development)
core-net-api-path|/api|Core Networking API path(Production)
core-net-api-path-dev|/api-v2|Core Networking API path(Development)
core-net-is-secure-transport|https://|Transport Security Toggle(Production)
core-net-is-secure-transport-dev|http://|Transport Security Toggle(Development)by toggling `[LYCore core].debug` _(BOOL)_, lib will use corresponding values to generate session manager.
example:
```bash
# production mode
https://app.luoyu.space/api# development mode
http://dev.luoyu.space/api-v2
```##### * You can add your own key-value configurations
and access it by...
```objective-c
// get configuration data (NSDictionary object)
[[LYCore core] conf];
```or
```objective-c
// get value for key
[[LYCore core] valueForConfWithKey:@"the-key-name"];
```### Custom request
Simply add category to LYCoreAPI, then you can write your own specified request method.
example:
**LYCoreAPI+Example.h**
```objc
#import@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
```this add an api error block for project error code handling.
**LYCoreAPI+Example.m**
```objc
#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
```### Locating
Core lib now can use CoreLocation to get current placemark, start with 1.0.31.
usage:
```objc
[[LYApp current] updateLocation:^(CLLocationCoordinate2D coordinate, CLPlacemark *place) {
// IF 'place' IS NOT NIL,
// MEANS SUCCESSFULLY GET CURRENT LOCATION PLACEMARK.
NSLog("%@", place);
}];
```### Author
[骆昱(Luo Yu)](http://luoyu.space)
Email: [[email protected]](mailto:[email protected])
Date: Tuesday, April 17, 2018