{"id":3404,"date":"2011-01-14T00:00:00","date_gmt":"2011-01-13T22:00:00","guid":{"rendered":"http:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/"},"modified":"2011-01-14T00:00:00","modified_gmt":"2011-01-13T22:00:00","slug":"how-to-get-display-name-from-nsscreen","status":"publish","type":"post","link":"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/","title":{"rendered":"How to get display name from NSScreen"},"content":{"rendered":"

While working on Wallpapery<\/a> I needed to get a given screens display name. There is no “displayName” method on NSScreen so I added a category to provide this functionality. Seems like others are looking for this too so I’m posting my code below.<\/p>\n

NSScreen+DisplayName.h<\/h4>\n
#import \n\n@interface NSScreen (DisplayName)\n\n- (NSString *)displayName;\n\n@end\n<\/code><\/pre>\n

NSScreen+DisplayName.m<\/h4>\n
#import \n#import \"NSScreen+DisplayName.h\"\n\n@implementation NSScreen (DisplayName)\n\n- (NSString *)displayName {\n    NSString *screenName = nil;\n\n    io_service_t framebuffer = CGDisplayIOServicePort([[[self deviceDescription] objectForKey:@\"NSScreenNumber\"] unsignedIntValue]);\n    NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(framebuffer, kIODisplayOnlyPreferredName);\n    NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];\n\n    if ([localizedNames count] > 0) {\n        screenName = [[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] retain];\n    }\n    else {\n        screenName = @\"Unknown\";\n    }\n\n    [deviceInfo release];\n    return [screenName autorelease];    \n}\n\n@end\n<\/code><\/pre>\n

You need to include the IOKit framework in your project.<\/p>\n

Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"

While working on Wallpapery I needed to get a given screens display name. There is no “displayName” method on NSScreen so I added a category to provide this functionality. Seems like others are looking for this too so I’m posting my code below. NSScreen+DisplayName.h #import @interface NSScreen (DisplayName) – (NSString *)displayName; @end NSScreen+DisplayName.m #import #import … Continue reading How to get display name from NSScreen<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"yoast_head":"\nHow to get display name from NSScreen • Peter Theill Site<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get display name from NSScreen • Peter Theill Site\" \/>\n<meta property=\"og:description\" content=\"While working on Wallpapery I needed to get a given screens display name. There is no “displayName” method on NSScreen so I added a category to provide this functionality. Seems like others are looking for this too so I’m posting my code below. NSScreen+DisplayName.h #import @interface NSScreen (DisplayName) - (NSString *)displayName; @end NSScreen+DisplayName.m #import #import … Continue reading How to get display name from NSScreen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/\" \/>\n<meta property=\"og:site_name\" content=\"Peter Theill Site\" \/>\n<meta property=\"article:published_time\" content=\"2011-01-13T22:00:00+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@theill\" \/>\n<meta name=\"twitter:site\" content=\"@theill\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.theill.com\/#website\",\"url\":\"https:\/\/www.theill.com\/\",\"name\":\"Peter Theill Site\",\"description\":\"What\\u2019s going on in the personal life of Peter Theill\",\"publisher\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.theill.com\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/#webpage\",\"url\":\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/\",\"name\":\"How to get display name from NSScreen • Peter Theill Site\",\"isPartOf\":{\"@id\":\"https:\/\/www.theill.com\/#website\"},\"datePublished\":\"2011-01-13T22:00:00+00:00\",\"dateModified\":\"2011-01-13T22:00:00+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"headline\":\"How to get display name from NSScreen\",\"datePublished\":\"2011-01-13T22:00:00+00:00\",\"dateModified\":\"2011-01-13T22:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\",\"name\":\"Peter\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.theill.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f4f96a08152550e603ee595403f3ba57?s=96&d=retro&r=g\",\"caption\":\"Peter\"},\"logo\":{\"@id\":\"https:\/\/www.theill.com\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","jetpack_shortlink":"https:\/\/wp.me\/p8TYI1-SU","jetpack-related-posts":[{"id":3411,"url":"https:\/\/www.theill.com\/blog\/2010\/08\/16\/how-to-send-mass-text-messages-from-your-own-number\/","url_meta":{"origin":3404,"position":0},"title":"How to send mass text messages from your own number","date":"August 16, 2010","format":false,"excerpt":"A couple of months ago we needed to make a service which would be able to send out sms text messages to a large number of people. The text message itself should come from a specific number so recipients would be able to reply back for more information. Another requirement\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3434,"url":"https:\/\/www.theill.com\/blog\/2019\/04\/13\/cinema-display-up-and-running-again\/","url_meta":{"origin":3404,"position":1},"title":"Cinema Display up and running again","date":"April 13, 2019","format":"image","excerpt":"I haven't been able to use my Apple Cinema Display because the cable didn't work and it was very difficult to get hold of a new one. Finally I found one on Ebay and was able to buy it for 30 bucks (and then an additional $60 in shipping \ud83e\udd26\u200d\u2642\ufe0f).\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/www.theill.com\/wp-content\/uploads\/2019\/04\/IMG_2815.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3414,"url":"https:\/\/www.theill.com\/blog\/2010\/01\/27\/facebook-css-for-will_paginate-gem\/","url_meta":{"origin":3404,"position":2},"title":"Facebook CSS for will_paginate gem","date":"January 27, 2010","format":false,"excerpt":"Today I needed to add pagination to my Danish beta application for handling your accounting called Hurtigmoms. Since I'm developing in Rails it was a logically choice to use \u201cwill_paginate\u201d to support pagination. Our prototype layout is using a Facebook header and so I wanted my pagination control to mimic\u2026","rel":"","context":"In "development"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3400,"url":"https:\/\/www.theill.com\/blog\/2011\/06\/08\/finding-apache-configuration-file-httpd-conf-location\/","url_meta":{"origin":3404,"position":3},"title":"Finding Apache configuration file (httpd.conf) location","date":"June 8, 2011","format":false,"excerpt":"Just a quick tip for programmers working with Apache. Sometimes I\u2019m asked where to find the Apache configuration file on a given server. Since it\u2019s possible to configure this there is no \u201cdefault location\u201d so I usually do: $ ps -ef | grep apache which gives me a list like\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3399,"url":"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/","url_meta":{"origin":3404,"position":4},"title":"A bash version of keep_releases known from Capistrano ruby scripts","date":"March 31, 2012","format":false,"excerpt":"Today I needed a clean up feature in my bash script similar to what\u2019s known from Capistrano when using the \u201ckeep_releases\u201d argument. I wasn\u2019t able to find a simple version so I created it myself. Maybe others find it useful too so here goes releases_path=\/data\/sites\/yoursite.com\/releases # change this keep_releases=5 versions=`ls\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3409,"url":"https:\/\/www.theill.com\/blog\/2010\/08\/19\/marketing-tip-include-link-to-your-app-in-newsletters\/","url_meta":{"origin":3404,"position":5},"title":"Marketing tip: Include link to your app in newsletters","date":"August 19, 2010","format":false,"excerpt":"I have registered on a lot of sites and opt-in for their newsletter to be notified of updates. One thing bugging me is, when a site sends a great mail in their newsletter but doesn\u2019t include a direct link to their web site. The mail is coming from their domain\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"amp_validity":null,"_links":{"self":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts\/3404"}],"collection":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/comments?post=3404"}],"version-history":[{"count":0,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts\/3404\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/media?parent=3404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/categories?post=3404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/tags?post=3404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}