Connecting a second ViewContoller to another Swift file

  1. Make sure the swift file looks like the default ViewContoller.swift file i.e. import UIKit, inherits from UIViewController, have at least the viewDidLoad function
  2. Click on the yellow dot that represents the view controller in the story board
  3. Select the identify inspector page
  4. In the Class drop down at the top, you should be able to select the name of your new class NOTE: you may have to save and or compile you app to get the new class to appear on the list.

Detecting iPad or iPhone in swift

To detect if the user is using an iPad or iPhone or something else in Swift do something like this: switch UIDevice.current.userInterfaceIdiom { case .phone: deviceLavel.text = "iPhone" case .pad: deviceLavel.text = "iPad" case .unspecified: deviceLavel.text = "unspecified" case .tv: deviceLavel.text = "tv" case .carPlay: deviceLavel.text = "carPlay" }

How to record an App Preview

1. Connect your iPhone or iPad to you Mac 2. Open Quick Time Player 3. From the File menu, Choose new Movie recording 4. Fromt the drop down next to the record button choose you iphone/ipad for video and microphone 5. Click record 6. Do steps 7. Click Stop 8. File | Save 9. Add name, click Save 10. Close quick time player 11. Open imovie 12. From the File menu, choose new app preview
you may have to go back to the projects screen first 13. If you get the app previews info screen click OK 14. Drag and drop your recording from steps 1-9 into the bottom half of the iMovies window 15.

Using a bigger Range of colours from code in Unity

  Create a new C# script in your project called CSSColors.cs and then copy and paste the code below into it. You should then be able to use the colour names specified anywhere in your project. public class CSSColors { // NOTE: The follwing color names come from the CSS3 specification, // Section 4.3 Extended Color Keywords // http://www.w3.org/TR/css3-color/#svg-color public static readonly Color AliceBlue = new Color32(240,248,255,255); public static readonly Color AntiqueWhite = new Color32(250,235,215,255); public static readonly Color Aqua= new Color32(0,255,255,255); public static

Optionals in Swift 3

Swift Optionals

A type the either has a "wrapped" value or is nil. e.g. let imagePaths = ["star": "/glyphs/star.png","portrait": "/images/content/portrait.jpg","spacer": "/images/shared/spacer.gif"] Getting a dictionary’s value using a key returns an optional value, so imagePaths["star"] has the type String? e.g. if let imagePath = imagePaths["star"] { print("The star image is at '(imagePath)'") } else { print("Couldn't find the image") } would print "The star image is at '/glyphs/star.png'" but "if let starPath = imagePaths[puppy]..... would print "Couldn't find the image" T

Convert numbers to and from strings in Swift

Convert numbers to and from strings in Swift // To convert a number to a string var costString = String(9.99) // To convert a string to an Int var wholeNumber = Int("27") // To convert a string to an Float let lessPrecisePI = Float("3.14") // To convert a string to an Double let morePrecisePI = Double("3.1415926536")

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer