How to list devices connected to Mac USB ports?

How to list devices connected to Mac and get them / dev / tty in Objective-C?

I would really like to do this for the application that I created over the last day or so.

I need to list the devices connected to the mac and find one that will meet my criteria for this application. How to find devices and list them / dev / tty as NSStrings in the list?

+4
source share
2 answers

Searching and accessing devices will provide you with additional information.

+2
source

Mounter.h header file

#include <sys/param.h> #include <sys/ucred.h> #include <sys/mount.h> @interface Mounter : NSObject { struct statfs *buf; int i, count; @private } -(void) getMountList; @end 

Implementation of the Mounter.m file:

 #import "Mounter.h" @implementation Mounter -(void) getMountList { NSFileManager *fm = [NSFileManager defaultManager]; count = getmntinfo(&buf, 0); for (i=0; i<count; i++) { NSString *path = [NSString stringWithUTF8String:buf[i].f_mntonname]; NSLog(@"Drivers: %@", path); } 
-1
source

Source: https://habr.com/ru/post/1345407/


All Articles