Category Archives: Programming

Installing Visual Studio Code on RHEL

RHEL, Fedora, and CentOS based distributions We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository: sudo rpm –import sudo sh -c ‘echo -e “[code]\nname=Visual Studio Code\nbaseurl=\nenabled=1\ngpgcheck=1\ngpgkey=” > /etc/yum.repos.d/vscode.repo’ Then update the package cache and install the package using dnf (Fedora 22 and… Read More »

Getting Started with CocoaPods

Installation make sure the ruby system is up to date $ sudo gem update –system install cocoapods $ sudo gem install cocoapods If you get an error message about fuzzy_match, try this command instead, $ sudo gem install -n /usr/local/bin cocoapods setup the pods $ pod setup To Test / use cocoa pods Create a… Read More »

Connecting a second ViewContoller to another Swift file

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 Click on the yellow dot that represents the view controller in the story board Select the identify inspector page In the Class drop down at the top, you should be able to… Read More »

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” }

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… Read More »

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 =… Read More »