Latest 0.1.2
Homepage https://github.com/huhk345/LAFramework
License MIT
Platforms ios 8.0
Dependencies AFNetworking, ReactiveObjC, CocoaLumberjack
Authors

CI Status
codecov.io

Base framework for iOS, inspired by Retrofit、Restless、JSPatch、Weex …

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

LAFramework is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'LAFramework' , :git => '[email protected]:huhk345/LAFramework.git’

post_install do |installer|
    require File.expand_path('runscript.rb', './Pods/LAFramework/LAFramework')
    RunScriptConfigurator::post_install(installer)
end

Introduction

LANetworking

Just define a protocol that inherits from LAWebService.

@GET("/users/{:user}/repos")
@Cache("1D")
- (LANSignal(GithubRepo))listRepos:(NSString*)user;

@GET("/repos/{:owner}/{:repo}")
@Headers({"Token":"AABB-CCDD-EE"})
- (LANSignal(void))listRepository:(NSString *)owner repo:(Part("repo") NSString *)arg;

The LANetworkingBuilder class generates an implementation of the GitHubService protocol.

id<GitHubService> service = [[LANetworkingBuilder initBuilderWithBlock:^(LANetworkingBuilder *builder) {
    builder.baseURL = [NSURL URLWithString:@"https://api.github.com"];
}] create:@protocol(GitHubService)];

Each RACSignal returned from the created GitHubService can make an asynchronous HTTP request to the remote webserver.

[[service listRepos:@"huhk345"] subscribeNext:^(LAURLResponse *response) {
    NSLog(@"reponse %@",response.responseObject);
}];

[[service listRepository:@"huhk345" repo:@"LAFramework"] subscribeNext:^(LAURLResponse *response) {
    NSLog(@"reponse %@",response.responseObject);
}];

LAJsonKit

Create a new Objective-C class for your data model and make it inherit the LAJsonObject class.
Declare properties in your header file with the name of the JSON keys:

@interface GithubRepo : LAJsonObject

@property (nonatomic,copy) NSString *archive_url;
@property (nonatomic,copy) NSString *assignees_url;

@end

Use annotations to modify the property

#undef  __CLASS__
#define __CLASS__ LAJsonTestObject

@interface LAJsonTestObject : LAJsonObject

@property (nonatomic,copy) NSString *aString;

@JsonMap("aMapString")
@property (nonatomic,copy) NSString *mapProperty;

@JsonIgnore
@property (nonatomic,copy) NSString *ignore;

@property (nonatomic,strong) NSDate *aDate;

@JsonFormat("LADate")
@JsonMap("aDate2")
@property (nonatomic,strong) NSDate *aDateTow;

@JsonTypeReference("GithubRepo")
@property (nonatomic,strong) NSArray *repos;

@property (nonatomic,assign) NSInteger aInteger;

@end

Custom data transformers

@implementation JSONValueTransformer (LAValueTransFormer)

- (NSDate *)LADateFromNSString:(NSString *)string{
    NSDateFormatter *formatter = [NSDateFormatter new];
    formatter.dateFormat = @"yyyy/MM/dd:HH/mm/ss";
    return [formatter dateFromString:string];
}

- (NSString *)JSONObjectFromLADate:(NSDate *)date{
    NSDateFormatter *formatter = [NSDateFormatter new];
    formatter.dateFormat = @"yyyy/MM/dd:HH/mm/ss";
    return [formatter stringFromDate:date];
}
@end

Author

LakeR,[email protected]

License

LAFramework is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "LAFramework",
    "version": "0.1.2",
    "summary": "iOS Base Framework.",
    "description": "This is a base framwork that constans Networking,Monitor,Cache,Mediator...",
    "homepage": "https://github.com/huhk345/LAFramework",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "LakeR": "[email protected]"
    },
    "source": {
        "git": "https://github.com/huhk345/LAFramework.git",
        "tag": "0.1.2"
    },
    "prefix_header_file": "LAFramework/Classes/LAPrefix.pch",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "LAFramework/Classes/**/*",
    "exclude_files": "LAFramework/Classes/LAPrefix.pch",
    "dependencies": {
        "AFNetworking": [
            "~> 3.1.0"
        ],
        "ReactiveObjC": [
            "~> 1.0.1"
        ],
        "CocoaLumberjack": [
            "~>2.3.0"
        ]
    },
    "preserve_paths": "LAFramework/runscript.rb",
    "subspecs": [
        {
            "name": "LADataCategory",
            "source_files": "LADataCategory/Classes/**/*",
            "libraries": "z"
        },
        {
            "name": "LAJsonKit",
            "source_files": "LAJsonKit/Classes/**/*",
            "public_header_files": "LAJsonKit/Classes/**/*.h",
            "preserve_paths": "LAJsonKit/Scripts/**/*"
        },
        {
            "name": "LAMediator",
            "source_files": "LAMediator/Classes/**/*"
        },
        {
            "name": "LACache",
            "source_files": "LACache/Classes/**/*",
            "dependencies": {
                "LAFramework/LADataCategory": []
            }
        },
        {
            "name": "LAWebViewBridge",
            "source_files": "LAWebViewBridge/Classes/**/*",
            "dependencies": {
                "LAFramework/LACache": []
            }
        },
        {
            "name": "LASystemInfo",
            "source_files": "LASystemInfo/Classes/**/*"
        },
        {
            "name": "LANetworking",
            "source_files": "LANetworking/Classes/**/*",
            "preserve_paths": "LANetworking/Scripts/**/*",
            "dependencies": {
                "LAFramework/LADataCategory": [],
                "LAFramework/LACache": [],
                "LAFramework/LAJsonKit": []
            }
        }
    ]
}

Pin It on Pinterest

Share This