objective c - How can i get list of installed applications on mac os x programmetically -



objective c - How can i get list of installed applications on mac os x programmetically -

this question has reply here:

enumerate installed applications on os x 3 answers

how can installed apps in mac os x programmatically either through c code or objective c code.

it possible app files using spotlight api. specifically, nsmetadataquery class..

-(void)doaquery { query = [[nsmetadataquery alloc] init]; // [query setsearchscopes: @[@"/applications"]]; // if want find applications in /applications folder nspredicate *predicate = [nspredicate predicatewithformat:@"kmditemkind == 'application'"]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(querydidfinishgathering:) name:nsmetadataquerydidfinishgatheringnotification object:nil]; [query setpredicate:predicate]; [query startquery]; } -(void)querydidfinishgathering:(nsnotification *)notif { int = 0; for(i = 0; i< query.resultcount; i++ ){ nslog(@"%@", [[query resultatindex:i] valueforattribute:kmditemdisplayname]); } }

you have various other attributes, such kmditemfsname. more attributes can found here

the terminal version of above is:

mdfind 'kmditemkind=application'

objective-c osx .app

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -