Latest 1.3.9
Homepage https://github.com/imwangxuesen/JsenKit
License MIT
Platforms ios 8.0, requires ARC
Authors

Description

JsenKit is iOS project common kit

It contains these functions:

  • Network request based on YYModel and AFNetworking
  • Custom Alert (will be update)
  • Custom HUD
  • Custom TabBar/Button(will be create)/TextView … UIKit modules
  • Frequently-used Category
  • Debug Tools eg:FPSLabel

Installation

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

pod 'JsenKit'

Useage

JsenNetwork

default response is json :
{
msg:"msg",
data:{}/[]
timestemp:1000
code:0
}

the value with "data" key will be create data model / model array

if you server response format is not like this. you could set responseFormat in JsenNetworkingConfig class property to convert it

JsenNetworkingConfig must be init . eg:

config host

    JsenNetworkingConfig *config = [JsenNetworkingConfig shareConfig];
    config.host = @"http://test.jsen.com/demo";

url and response data model, if no data model,or don’t wanna create model, could be omited.
Jsen_HomeList_API(is @"/home/list" defined) api will response data JsenHomeCellModel json

config.modelClass = @{
        Jsen_HomeList_API:NSClassFromString(@"JsenHomeCellModel")
                          };

global parameters

    config.globalParametersBlock = ^NSDictionary *{
        return @{
                //some keys and values
        };
    };

response error code notification
eg token timeout
add notification

JsenNetworkingCustomHttpErrorNotificationKey in “JsenNetworkingConfig.h” file

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commonNetworkErrorNotification:) name:JsenNetworkingCustomHttpErrorNotificationKey object:nil];

     // resive notification 
     - (void)commonNetworkErrorNotification:(NSNotification *)notifi {
        JsenNetworkingFailedResponse *response = [notifi object];
        NSLog(@"%@",notifi);
     }

custom error code notification
if response code is @10030 , notification center will resive JsenNetworkingCustomHttpErrorNotificationKey’s message


    config.customErrorStatusCode = @{
                                     @(@10030.integerValue):@"token timeout.please relogin"
                                     };

request timeout
if you wanna more custom, you should see timeoutInterval property

    config.defaultTimeoutInterval = 30;

networking reachability

[JsenNetworkingReachabilityManager manager].currentStatus could get networking current status when startMonitoring

    [[JsenNetworkingReachabilityManager manager] setJsenReachabilityStatusChangeBlock:^(JsenNetworkingReachabilityStatus status) {
        //to do something
    }];
    [[JsenNetworkingReachabilityManager manager] startMonitoring];

Send Request

    NSDictionary *parameters = @{
                                 @"id":@123,
                                 @"page":@1
                                 };
    [[JsenNetworkingManager manager] post:Jsen_HomeList_API parameters:parameters progress:nil success:^(JsenNetworkingSuccessResponse * _Nonnull response) {
               //success
                JsenHomeCellModel *model = response.data;

                //if response json is array 
                //NSArray *cellModels = response.data;

    } failed:^(JsenNetworkingFailedResponse * _Nonnull response) {
                //error
    } finished:^{
           //finished
    }];

Latest podspec

{
    "name": "JsenKit",
    "version": "1.3.9",
    "summary": "A iOS development of general engineering framework, including the commonly used network request package, category method, etc",
    "description": "A iOS development of general engineering framework, including the commonly used network request package, category method, etc.",
    "homepage": "https://github.com/imwangxuesen/JsenKit",
    "license": "MIT",
    "authors": {
        "WangXuesen": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/imwangxuesen/JsenKit.git",
        "tag": "1.3.9"
    },
    "resources": "JsenKit/JsenProgressHUD/*.png",
    "requires_arc": true,
    "default_subspecs": "All",
    "subspecs": [
        {
            "name": "All",
            "dependencies": {
                "JsenKit/JsenAlert": [],
                "JsenKit/JsenCategory": [],
                "JsenKit/JsenDebugTool": [],
                "JsenKit/JsenNetworking": [],
                "JsenKit/JsenProgressHUD": [],
                "JsenKit/JsenTabBarController": []
            }
        },
        {
            "name": "JsenAlert",
            "source_files": "JsenKit/JsenAlert/*.{h,m}",
            "dependencies": {
                "JsenKit/JsenCategory": []
            }
        },
        {
            "name": "JsenCategory",
            "source_files": "JsenKit/JsenCategory/*.{h,m}"
        },
        {
            "name": "JsenDebugTool",
            "source_files": "JsenKit/JsenDebugTool/*.{h,m}"
        },
        {
            "name": "JsenNetworking",
            "source_files": "JsenKit/JsenNetworking/*.{h,m}",
            "dependencies": {
                "AFNetworking": [],
                "YYModel": []
            }
        },
        {
            "name": "JsenProgressHUD",
            "source_files": "JsenKit/JsenProgressHUD/*.{h,m}"
        },
        {
            "name": "JsenTabBarController",
            "source_files": "JsenKit/JsenTabBarController/*.{h,m}"
        },
        {
            "name": "JsenUI",
            "source_files": "JsenKit/JsenUI/*.{h,m}"
        }
    ]
}

Pin It on Pinterest

Share This