Giter Club home page Giter Club logo

ppsping's Introduction

PPSPing

new:最新修复了xcode9 check_compile_time导致编译失败的错误,在iOS11中,将宏定义改成了__Check_Compile_Time

iOS端的一个ping网络工具,修复了之前不能够并发Ping的bug和不能够在子线程中发起的bug

此次版本还加入了pod支持,可以通过pod集成

集成方式

源码

直接将PPSPing下的源码拷贝到工程目录中,在使用的时候直接引入PPSPingServices文件即可

pod方式引入
pod 'PPSPing', '~> 0.3.0'

回调说明

ping的结果与电脑端的ping方式相似,数据格式相同

使用方式

@interface PPSAppDelegate()

@property (nonatomic, strong) PPSPingServices *service;

@end

@implementation PPSAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.service = [PPSPingServices serviceWithAddress:@"www.163.com"];
    [self.service startWithCallbackHandler:^(PPSPingSummary *pingItem, NSArray *pingItems) {
        NSLog(@"%@",pingItem);
    }];
    return YES;
}

@end

注意:在使用时,需要service存在强引用,不然不能够收到回调结果

错误使用方式
@interface PPSAppDelegate()

//@property (nonatomic, strong) PPSPingServices *service;

@end

@implementation PPSAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    PPSPingServices *service = [PPSPingServices serviceWithAddress:@"www.163.com"];
    [service startWithCallbackHandler:^(PPSPingSummary *pingItem, NSArray *pingItems) {
        NSLog(@"%@",pingItem);
    }];
    return YES;
}

@end

上面这种使用方式,将得不到回调结果,在block执行完成后,service已经销毁

看一下效果图:

后面如果还有时间,会接着完善

ppsping's People

Contributors

yangqian111 avatar ppsheep avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.