Get User Account Image

后端 未结 3 1062
故里飘歌
故里飘歌 2020-12-15 14:09

Simply: how do I get the user\'s account image?

I\'m using Cocoa on Mac.

3条回答
  •  无人及你
    2020-12-15 14:25

    The Address Book method doesn't work if the user deletes the vcard.

    I use the CBIdentity method that never breaks, as Dave says:

    + (NSImage *)userImage
    {
        CBIdentity *identity = [CBIdentity identityWithName:NSUserName() authority:[CBIdentityAuthority defaultIdentityAuthority]];
        return [identity image];
    }
    

    In order to use CBIdentity you need to add the Collaboration Framework to your targets and use the following include directive

    #import 
    

提交回复
热议问题