• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OT: Swift Code Autoformatter?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OT: Swift Code Autoformatter?


  • Subject: Re: OT: Swift Code Autoformatter?
  • From: sqwarqDev <email@hidden>
  • Date: Fri, 15 Jan 2016 21:07:25 +0700

> On 15 Jan 2016, at 17:38, sqwarqDev <email@hidden> wrote:
>
> tell application "Xcode"
> 	tell source document 1
> 		set _sourceCode to contents
>
> 		-- do shell script ....//do all your formatting here


BTW, please don’t put a ‘do shell script’ inside a tell block like I did there; that's a cardinal AppleScript sin  (careless pseudocoding, sorry). Better structure:

####

set _sourceCode to ""
set _formattedCode to ""

tell application "Xcode"
	tell source document 1
		set my _sourceCode to contents
	end tell
end tell

set _formattedCode to (do shell script somethingOrOther & _sourceCode) # operate on the _sourceCode here

tell application "Xcode"
	tell source document 1
		set contents to my _formattedCode
	end tell
end tell

####




Best

Phil
@sqwarqdev










_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >OT: Swift Code Autoformatter? (From: Charles Jenkins <email@hidden>)
 >Re: OT: Swift Code Autoformatter? (From: sqwarqDev <email@hidden>)

  • Prev by Date: Re: OT: Swift Code Autoformatter?
  • Next by Date: Auto Layout and Multiline labels iOS 8
  • Previous by thread: Re: OT: Swift Code Autoformatter?
  • Next by thread: drawRect: wrong scale in a programmatically created window
  • Index(es):
    • Date
    • Thread