如何获取用户的Mac的图标? [英] How do I get the icon of the user's Mac?

查看:157
本文介绍了如何获取用户的Mac的图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Objective-C和Cocoa,有没有人知道如何获取用户计算机的图标(在Finder中的设备和网络下显示的图标)?不是硬盘图标,实际的一个用户的设备。

Using Objective-C and Cocoa, does anyone know how to get the icon for a user's computer (the one that shows under "Devices" and "Network" in Finder)? Not the harddisk icon, the actual one for a user's device. It ranges from a MacBook icon to the Mac Pro icon to a Windows blue screen of death monitor icon.

我尝试过以下几行:

NSImage *icon = [[NSWorkspace sharedWorkspace] 
                  iconForFileType: NSFileTypeForHFSTypeCode(kComputerIcon)];

但这只是一直返回相同的图标,显然。我也尝试过 iconForFile:方法,但我不知道一个文件路径作为参数。

But that just returns the same icon all the time, obviously. I've also tried the iconForFile: method but I don't know of a file path to use as the parameter. Can anybody point me in the right direction?

推荐答案

[NSImage imageNamed: NSImageNameComputer]

这将返回当前计算机的图标

This will return the icon of the current computer

这篇关于如何获取用户的Mac的图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆