objective c - How can I get all supported screen resolutions on mac OSX Swift -


i want code that

1)grabs current screen resolution, (solved).

for example : current screen display code :

system_profiler spdisplaysdatatype |grep resolution

2)grabs supported resolution shown in picture below (unsolved).

or objective c code useful

enter image description here

swift code

    var displayconfig: cgdisplayconfigref = nil     let maindisplayid = cgmaindisplayid()      var displaymode = cgdisplaycopydisplaymode(maindisplayid).takeretainedvalue()     var width = cgdisplaymodegetwidth(displaymode)     var height = cgdisplaymodegetheight(displaymode)      print("current size: \(width)x\(height)\n")     print("available sizes:\n")      var modes = cgdisplaycopyalldisplaymodes(maindisplayid, nil).takeretainedvalue()     let modescount = cfarraygetcount(modes) - 1      in 0...modescount {         var mode: cgdisplaymoderef = unsafebitcast(cfarraygetvalueatindex(modes, i), cgdisplaymoderef.self)          var width = cgdisplaymodegetwidth(mode)         var height = cgdisplaymodegetheight(mode)         print("\t\(width)x\(height)\n") 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -