Latest 1.0.33
Homepage https://github.com/blodely/LYCore
License MIT
Platforms ios 8.0
Dependencies AFNetworking, FCFileManager
Frameworks Foundation, UIKit, CoreLocation
Authors

General core lib for apps.

How to use:

Simply addpod '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:

# 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…

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

or

// 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

#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

this add an api error block for project error code handling.

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

Locating

Core lib now can use CoreLocation to get current placemark, start with 1.0.31.

usage:

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

Author

骆昱(Luo Yu)

Email: [email protected]

Date: Tuesday, April 17, 2018

Latest podspec

{
    "name": "LYCore",
    "version": "1.0.33",
    "summary": "Core libs for iOS app.",
    "description": "Core library 4 iOS app.",
    "homepage": "https://github.com/blodely/LYCore",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Luo Yu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/blodely/LYCore.git",
        "tag": "1.0.33"
    },
    "social_media_url": "https://weibo.com/blodely",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": [
        "LYCore/Classes/network/*",
        "LYCore/Classes/model/*",
        "LYCore/Classes/base_view/*",
        "LYCore/Classes/viewc/*",
        "LYCore/Classes/category/*",
        "LYCore/Configuration/*.plist",
        "LYCore/Classes/*"
    ],
    "frameworks": [
        "Foundation",
        "UIKit",
        "CoreLocation"
    ],
    "dependencies": {
        "AFNetworking": [
            "~> 3.2.1"
        ],
        "FCFileManager": [
            "~> 1.0.20"
        ]
    },
    "ios": {
        "dependencies": {
            "LYCategory": [],
            "Masonry": [
                "~> 1.1.0"
            ]
        }
    }
}

Pin It on Pinterest

Share This