is there a way to shorten prefences list in swift

is there a way to shorten prefences list in swift



is there a way to set this in one line
by example



appwindow(setContentSize(NSSize(width: 400, height: 23),titlebarAppearsTransparent = true) ect



rather than having to spell them one by one


appWindow.setContentSize(NSSize(width: 400, height: 23))
appWindow.titlebarAppearsTransparent = true
appWindow.isMovableByWindowBackground = true
appWindow.backgroundColor = NSColor.white //Maybe have it gray instead so we can remove this?
appWindow.setFrameAutosaveName(NSWindow.FrameAutosaveName(rawValue: "myGoodGoodApp"))
appWindow.makeKeyAndOrderFront(nil)
appWindow.contentView?.addSubview(gunTrigger)





Nop there isn't, the only thing you could do is make a function
– ValW
Sep 5 '18 at 13:22





Why do you wish to put it all on one line? It's must easier to read, debug, and change the code when it is on separate lines.
– rmaddy
Sep 5 '18 at 13:22





@maddy it just seem professial app wouldnt have it this way i cant recal seeing pro apps who do it this way
– jessyjannis
Sep 5 '18 at 13:24





@ValW a function like a forEach with $0 ?
– jessyjannis
Sep 5 '18 at 13:25





Btw putting it in one line seems way unprofessional then that way. professional != complicated. Easy to read code is mostly good code.
– ValW
Sep 5 '18 at 13:28




1 Answer
1



You can use an immediately executed closure to give yourself a scope in which you can have a short variable name, while allowing you to preserve a better, longer name in the rest of the usage. It's a particularly useful technique for value types, as this allows you to keep the mutability constrained to the closure.


let appWindow: NSWindow =
let w = NSWindow()
w.setContentSize(NSSize(width: 400, height: 23))
w.titlebarAppearsTransparent = true
w.isMovableByWindowBackground = true
w.backgroundColor = NSColor.white //Maybe have it gray instead so we can remove this?
w.setFrameAutosaveName(NSWindow.FrameAutosaveName(rawValue: "myGoodGoodApp"))
w.makeKeyAndOrderFront(nil)
w.contentView?.addSubview(gunTrigger)
return w
()



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế