This page documents the methods available in the Quick programming language. These methods are designed to allow for high level actions to be taken with a minimum of code. It is our intent to continue to expand this list of methods, based on our roadmap and upon feedback from users of the language.

Table of Contents

Outputting to Console

print:

Outputs a string to the debug console. 'Print' statements are not rendered to code on export.

Arguments:
print : String - The string to print to the console.

Quick Example Code
print("Hello World")


printAppVariables

Outputs all current app variables to the console. 'Print' statements are not rendered to code on export.

Arguments: None

Quick Example Code
printAppVariables()


printScreenVariables

Outputs all current screen variables to the console. 'Print' statements are not rendered to code on export.

Arguments: None

Quick Example Code
printScreenVariables()


Networking

getJSONArrayFromURL:headers:

Retrieves a JSON Array from a URL and translates it to a Quick Array.

Arguments:
getJSONArrayFromURL : String - The URL to retrieve the JSON from.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
getJSONArrayFromURL("http://www.example.com/jsonArray", headers: {"X-CLIENT-HEADER": "Quick"})


getJSONDictionaryFromURL:headers:

Retrieves a JSON Dictionary from a URL and translates it to a Quick Dictionary.

Arguments:
getJSONDictionaryFromURL : String - The URL to retrieve the JSON from.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
getJSONDictionaryFromURL("http://www.example.com/jsonDictionary", headers: {"X-CLIENT-HEADER": "Quick"})


getImageFromURL:headers:

Retrieves an image from a URL and translates it to a Quick Image.

Arguments:
getImageFromURL : String - The URL to retrieve the image from.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
getImageFromURL("http://www.example.com/image.jpg", headers: {"X-CLIENT-HEADER": "Quick"})


postWithStringResponseJSON:toURL:headers:

POST's a piece of JSON to a given URL, and translates the response into a Quick String.

Arguments:
postWithStringResponseJSON : Array or Dictionary - The content of the POST request.
toURL : String - The URL to post to.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
postWithStringResponseJSON([""Hello World""], toURL: "http://www.example.com/postEndpoint", headers: {"X-CLIENT-HEADER": "Quick"})


postWithDictResponseJSON:toURL:headers:

POST's a piece of JSON to a given URL, and translates the response into a Quick Dictionary.

Arguments:
postWithDictResponseJSON : Array or Dictionary - The content of the POST request.
toURL : String - The URL to post to.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
postWithDictResponseJSON([""Hello World""], toURL: "http://www.example.com/postEndpoint", headers: {"X-CLIENT-HEADER": "Quick"})


postForm:toURL:headers:

POST's a dictionary to a given URL as multipart form data.

Arguments:
postForm: Dictionary - The content of the POST request.
toURL : String - The URL to post to.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
postForm({"name": ""Hello World""}, toURL: "http://www.example.com/formEndpoint", headers: {"X-CLIENT-HEADER": "Quick"})


signInViaOAuthWithConsumerKey:consumerSecret:authorizeURL:tokenURL:responseType:callbackURL:scope:state:

Performs an OAuth signin process and returns the OAuth Token.

Arguments:
signInViaOAuthWithConsumerKey : String
consumerSecret : String
authorizeURL : String
tokenURL : String
responseType : String
callbackURL : String
scope : String
state : String


getDictionaryFromXMLAtURL:headers:

Retrieves an XML document form a given URL and translates it into a Quick Dictionary

Arguments:
getDictionaryFromXMLAtURL : String - The URL to get the XML from.
headers : Dictionary - Key-value pairs to set as headers on the network request.

Quick Example Code
getDictionaryFromXMLAtURL("http://www.example.com/xmlEndpoint", headers: {"X-CLIENT-HEADER": "Quick"})


Working with Arrays

writeArray:toFile:

Serializes an array to the filesystem.

Arguments:
writeArray : Array - The array to write.
toFile : String - The name of the file.

Quick Example Code
writeArray([1, 2, 3], toFile: "Integers")


loadArrayFromFile:

Deserializes an array from the filesystem.

Arguments:
loadArrayFromFile : String - The name of the file.

Returns : Array.

Quick Example Code
arr = loadArrayFromFile("Integers")


countArray:

Counts the number of elements in an array.

Arguments:
countArray : Array - The array to count.

Returns : Integer

Quick Example Code
count = countArray(myArray)


addItem:toArray:

Returns an array with the appended item.

Arguments:
addItem: Any - The item to add into the array.
toArray: Array - The array to count.

Returns : Array

Quick Example Code
myArray = addItem(42, toArray: myArray)


removeItemAtIndex:fromArray:

Returns an array without the item at the specified index.

Arguments:
removeItemAtIndex: Any - The index of the item to remove.
fromArray: Array - The starting array.

Returns : Array

Quick Example Code
myArray = removeItemAtIndex(0, fromArray: [1, 2, 3])


sortArray:

Returns a sorted array. If the array contains more than one type, the type ordering for sorting is Boolean, Integer, Float, String, Color, Array and Dictionary.

Arguments:
sortArray: Array - The starting array.

Returns : Array

Quick Example Code
myArray = sortArray([3, 2, 1])


replaceItemAtIndex:withItem:inArray:

Returns an array where an item that's at a certain index in an array is replaced with another item.

Arguments: replaceItemAtIndex: Integer - The index to replace at.
withItem: Any - The item to replace with.
inArray: Array - The starting array.

Returns : Array

Quick Example Code
exists = replaceItemAtIndex(0, withItem:4, inArray: [3, 2, 1])


itemExists:inArray:

Checks if an instance of a given item is in an array

Arguments: itemExists: Any - The item to check for.
inArray:: Array - The starting array.

Returns : Boolean

Quick Example Code
exists = itemExists(3, inArray: [3, 2, 1])


Working with Dictionaries

writeDictionary:toFile:

Serializes a dictionary to the filesystem.

Arguments:
writeDictionary : Dictionary - The dictionary to write.
toFile : String - The name of the file.

Quick Example Code
writeDictionary({"Test": [1, 2, 3]}, toFile: "Integers")


loadDictionaryFromFile:

Deserializes a dictionary from the filesystem.

Arguments:
loadDictionaryFromFile : String - The name of the file.

Returns : Dictionary.

Quick Example Code
arr = loadDictionaryFromFile("Integers")


keyExists:inDictionary:

Checks if an instance of a given key is in a dictionary

Arguments: keyExists: String - The key to check for.
inDictionary: Dictionary - The dictionary.

Returns : Boolean

Quick Example Code
exists = keyExists("test", inDictionary: {"test": [1, 2, 3]})


countDictionary:

Counts the number of keys in a dictionary.

Arguments:
countDictionary : Dictionary - The dictionary to count.

Returns : Integer

Quick Example Code
count = countDictionary(myDictionary)


getKeysForDictionary:

Returns an array of all the keys in a dictionary.

Arguments:
getKeysForDictionary : Dictionary - The dictionary.

Returns : Array

Quick Example Code
keys = getKeysForDictionary(myDictionary)


addItem:forKey:toDictionary:

Returns a dictionary which includes the given key and item. Replaces any existing item with the same key.

Arguments:
addItem : Any - The item to add.
forKey : String - The key to add the item under.
toDictionary : Dictionary - The dictionary.

Returns : Array

Quick Example Code
myDictionary = addItem(42, forKey: "answer", toDictionary: myDictionary)


removeItem:fromDictionary:

Returns a dictionary with no item for the given key.

Arguments:
removeItem : String - The key to remove the item for.
fromDictionary : Dictionary - The dictionary.

Returns : Array

Quick Example Code
myDictionary = removeItem("answer", fromDictionary: myDictionary)


Working with Strings

writeString:toFile:

Serializes a string to the filesystem.

Arguments:
writeString : String - The string to write.
toFile : String - The name of the file.

Quick Example Code
writeString("Test", toFile: "My Great Test")


loadStringFromFile:

Deserializes a string from the filesystem.

Arguments:
loadStringFromFile : String - The name of the file.

Returns : String.

Quick Example Code
str = loadStringFromFile("My Great Test")


replaceString:inString:withString:

Returns a string where a substring has been replaced by the given string.

Arguments:
replaceString : String - The substring to replace.
inString : String - The original string.
withString : String - The replacement string.

Returns : String

Quick Example Code
helloWorld = replaceString("Hi", inString: "Hi World!", withString: "Hello")


capitalizeString:

Returns a string where the first letter of each word is capitalized.

Arguments:
capitalizeString : String - The starting string.

Returns : String

Quick Example Code
headline = capitalizeString("the quick brown fox, etc...")


encodeBase64:

Returns a Base64 encoded version of the given string. Useful when working with web API's that require basic auth.

Arguments:
encodeBase64 : String - The original string.

Returns : String

Quick Example Code
encoded = encodeBase64("Hello World!")


Setting Broadly Scoped Variables

Quick lets you set two kinds of variables that are available between scripts. Screen Variables are available to all of the scripts within a single screen. App Variables are available to every script in the app, regardless of what screen you're on.

setAppVariable:to:

Sets an app variable, which will be available to other scripts in the app.

Arguments:
setAppVariable : Any - The value of the set variable.
to : String - The key to set and retrieve the variable.

Quick Example Code
setAppVariable("My Great Test Content", to: "Test")


getAppVariable:

Gets an app variable for use in your script.

Arguments:
getAppVariable : String - The key to set and retrieve the variable.

Quick Example Code
testVar = getAppVariable("Test")


setScreenVariable:to:

Sets an screen variable, which will be available to other scripts on the same screen.

Arguments:
setScreenVariable : Any - The value of the set variable.
to : String - The key to set and retrieve the variable.

Quick Example Code
setScreenVariable("My Great Test Content", to: "Test")


getScreenVariable:

Gets an screen variable for use in your script.

Arguments:
getScreenVariable : String - The key to set and retrieve the variable.

Quick Example Code
testVar = getScreenVariable("Test")


Working with Screens

pushScreenWithName:context:

Pushes a screen with a given parameter. Any data passed in the context parameter can be retrieved using getScreenVariable: on the pushed screen.

If the screen doesn't exist, a blank screen with the appropriate identifier is created.

Arguments:
pushScreenWithName : String - The identifier for the screen.
context : Dictionary - Screen Variables to use on the pushed screen.

Quick Example Code
pushScreenWithName("Address Bool", context: {"username": "bob"})


popScreen:

Return to the previous screen on the navigation stack.

Arguments: none

Quick Example Code
popScreen()


popToRootScreen:

Return to the first screen on the navigation stack.

Arguments: none

Quick Example Code
popToRootScreen()


showAlertWithTitle:informationalText:buttons:

Shows a modal alert dialog with the given title and informational text. Buttons are provided as an array of Strings.

Arguments:
showAlertWithTitle : String - The string to show prominently in the alert.
informationalText : String - The string to show less prominently in the alert.
buttons : Array of Strings - The buttons that will dismiss the alert.

Returns: String - The name of the button that was selected.

Quick Example Code
showAlertWithTitle("I'm an Alert!", informationalText:"Thou art alerted.", buttons: ["Ok"])


showActionSheetWithTitle:informationalText:buttons:

Shows an 'action sheet' style alert dialog with the given title and informational text. Buttons are provided as an array of Strings.

Arguments:
showActionSheetWithTitle : String - The string to show prominently in the action sheet.
informationalText : String - The string to show less prominently in the action sheet.
buttons : Array of Strings - The buttons that will dismiss the action sheet.

Returns: String - The name of the button that was selected.

Quick Example Code
showActionSheetWithTitle("I'm an Action Sheet!", informationalText:"Thou art sheeted.", buttons: ["Ok"])


Miscellaneous

getImageFromCamera:

Shows the camera and lets the user take a picture.

Arguments: none

Returns: Image

Quick Example Code
image = getImageFromCamera()


getImageFromLibrary:

Shows the photo library and lets the user select a picture.

Arguments: none

Returns: Image

Quick Example Code
image = getImageFromLibrary()


randomWithLowBound:highBound:

Picks a random integer between two integers (inclusive).

Arguments:
randomWithLowBound : Integer - The lowest number that the random number could be.
highBound : Integer - The highest number that the random number could be.

Returns: Integer

Quick Example Code
random = randomWithLowBound(0, highBound: 5)


sendEmail:withTitle:withBody:

Shows an email sheet to send a message.

Arguments:
sendEmail : String - The email address to address the message to.
withTitle : String - The subject of the email message.
withBody : String - The body of the email message.

Quick Example Code
sendEmail("capcom@launchwithcodeless.com", withTitle:"A question about Codeless", withBody:"When are you adding more methods?")


dismissKeyboard:

Hides the onscreen keyboard.

Arguments: none

Quick Example Code
dismissKeyboard()