要运行示例项目,首先需要克隆仓库,然后从示例目录中运行pod install
。
当您需要了解磁盘事件时,添加以下代码行。
[[IdentifyUSBMassStorage shareManager] addMassStorageDeviceEventListener:self];
并实现事件代理
#pragma mark - IdentifyUSBMassStorageEvent
-(NSDictionary*)matchingDict{
//Example of matching: Trancend thumbdrive, pid: 0x1000, vid:0x8564
return @{ kDiskDevicePropertyVendorID:@(0x8564), kDiskDevicePropertyProductID:@(0x1000) };
// //Example of matching: pid: 0x1000 only.
// return @{ kDiskDevicePropertyProductID:@(0x1000) };
//
// //Example of matching: vid:0x8564 only.
// return @{ kDiskDevicePropertyVendorID:@(0x8564) };
//
// //Example of no restriction. matching all.
// return nil;
}
-(void)massStorageDeviceDidPlugIn:(DADiskRef)disk{
}
-(void)massStorageDeviceDidPlugOut:(DADiskRef)disk{
}
IdentifyUSBMassStorage可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中即可
pod "IdentifyUSBMassStorage"
raxcat liu,[邮件保密]
IdentifyUSBMassStorage遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。