.h文件
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
extern NSString *const NetworkDownloadSpeedNotificationKey;
extern NSString *const NetworkUploadSpeedNotificationKey;
extern NSString *const NetworkSpeedNotificationKey;
@interface NetworkSpeed : NSObject
@property (nonatomic, copy, readonly) NSString *downloadNetworkSpeed;
@property (nonatomic, copy, readonly) NSString *uploadNetworkSpeed;
- (void)startNetworkSpeedMonitor;
- (void)stopNetworkSpeedMonitor;
@end
NS_ASSUME_NONNULL_END
.m文件
#import "NetworkSpeed.h"
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <net/if_dl.h>
NSString *const NetworkDownloadSpeedNotificationKey = @"NetworkDownloadSpeedNotificationKey";
NSString *const N