swift
-
How to repeat a string in Swift 4
Ever wanted to repeat a string x number of times? There is a simple way to do it in Swift 4. Check it out: let numberOfRepeats = 3 String(repeating: “stringToRepeat”, count: numberOfRepeats) So the “stringToRepeat” will repeat numberOfRepeats times.
-
How To Customize UITabBar Icon Highlight Color iOS Swift 5
So Tabbed applications are pretty common nowadays. It is a great design pattern to follow when you are setting up your application. One of the customizations I was trying to accomplish today was to make the icon highlight in different colors. Personally, I wanted my current tab to show up in orange instead of blue,
Read More… -
How To Use List Of Objects With User Defaults iOS & Swift 4
Ever wanted to store a list of objects into user defaults for reference later? Lets check out the below code to do just that. // to retrieve arrays from user defaults UserDefaults.standard.array(forKey: “yourArrayKey”) // to store arrays of objects into user defaults UserDefaults.standard.set(arrayToStore, forKey: “yourArrayKey”) // to delete the object from your user defaults UserDefaults.standard.removeObject(forKey:
Read More… -
How To Display An Alert In iOS & Swift 5
In iOS, there will be times where you will want to give the user some feedback depending on the situation. It could be because of a success or a failure whether it be during object creation or authentication. Below is a code snippet to create an AlertViewController and then present it. We can add actions
Read More… -
How to turn on the flashlight with iOS Swift
iOS gives us access to the flashlight if there is currently one available on the phone. Technically, its called a torch but whatever lol… Here is a code snippet on how to turn on the torch. import AVFoundation func toggleTorch(on: Bool) { guard let device = AVCaptureDevice.default(for: AVMediaType.video) else { return } if device.hasTorch {
Read More… -
WWDC 2017 iOS Notes
WWDC 2017 happened last week and there is a huge amount of videos covering new iOS technologies. I’ll try to summarize the videos I watch in this post. Introduction to CoreML
Recent Comments