Tag: Swift 3

  • iOS Swift Save|Load Custom Class Variables As Encoded Object

    iOS Swift Save|Load Custom Class Variables As Encoded Object

    By using NSKeyedArchiver.archivedData, NSKeyedUnarchiver.unarchiveObject you can actually store the data as compressed zip in the device and recall/unzip them to your class structure Model Class class User: NSObject, NSCoding { // Common var userId: Int = 0 var userFullName: String = “” var userUsername: String = “” var userBiography: String = “” var userRegisterDate: String =…

  • iOS Swift Navigation With Manuel Segue

    iOS Swift Navigation With Manuel Segue

    Unwind Structure Example @IBAction func unwindToTheVC(segue: UIStoryboardSegue) { if let source = segue.source as? OtherVC { print(“From OtherVC”) } }     Manuel Segue Example func gotoSegue(_ sender:Any){ guard let destination = UIStoryboard(name:”Main”, bundle:nil).instantiateViewController(withIdentifier: “TheTableViewController”) as? TheTableViewController else { print(“Could not instantiate view controller with identifier of type SecondViewController”) return } destination.variablesToSet = vars destination.unwindTo…

  • iOS Swift Find Exist Fond Families In The Project

    iOS Swift Find Exist Fond Families In The Project

    This code showing the font families and real name of the fonts.   for family: String in UIFont.familyNames { print(“\(family)”) for names: String in UIFont.fontNames(forFamilyName: family) { print(“== \(names)”) } }  

  • Making iOS Swift App Without Storyboard, Just Programmatically!

    Making iOS Swift App Without Storyboard, Just Programmatically!

    Storyboard is a good thing but has some side unwanted effect. You can find many discussion about it. Personally I don’t like it so much especially when I make an application without default navigation system it is useless, slow and makes me tired. I prefer creating my UIViews separately and link them to their UIViewController’s…

  • iOS Swift Initialising XIB And Bind To The Controller Without Storyboard

    iOS Swift Initialising XIB And Bind To The Controller Without Storyboard

    It is very useful to able to initialise  xib files independently from storyboard. Here is what to do with a line of code: //Calling the initializer in the ViewController convenience override init() { // ViewName is by convenience same name. // I use like: BlahV.xib BlahVC.swift self.init(nibName: “BlahV.xib”, bundle: nil) //initializing the view Controller form specified…

  • iOS Swift Detecting Device Rotation

    How to detect device rotation event in iOS Swift 3: Detecting device rotation is not a big secret but doing this in a clean way is important. I mean adding and removing the observers in correct time/place. Many developer are adding  observers without removing with exit. This leads memory leaks and performance issues.   override func…

  • UIView With Rounded Background Designable In Storyboard

    UIView With Rounded Background Designable In Storyboard

    This class can be inherited as a base class for having any time a framed background behind the UIView. It is also designable in the Storyboard. I’ve used it in UITableViewCell for my customCell view.

  • iOS Swift 3 Playground UIButton Action

    Experimenting on Playground is very useful especially when we work on some interactive UI element like UIButton. This is a simple example that show how to use UIButton and new Swift command PlaygroundSupport (XCPlaygroundPage depreciated)