Import UIKit: An Xcode Story
Swift Programming & Poetic Words ☕️
👉 It has been more than a year since I started "Swift programming and poetic words, and I really want to bring it back after so long of not implementing poetry into my Swift code 🙂 I've been a technical writer for almost three years, and the majority my articles are all technology-based! But when I started my medium account and swift programming and poetic words, I found many computer science students and programmers enjoyed the implementation of poetry and programming. So, after a long break, I'm returning to LinkedIn and Medium.
👉 I'm going try my best to develop an algorithm for each poem I write, but I'm also still mastering Swift programming language, so I can't say it will be perfect. Please reach out to me if there is an error, as I'll gladly fix it 📚
❤️ Enjoy
In a UIViewController, once full of hue,
An IBOutlet bound me to you.
But life’s not static, like let or var
Sometimes we drift, like views from afar.
Finally, deinitialization was called, as classes do,
Releasing memories of our love.
No strong reference could make it stop,
like ARC clean up, we went our way.
We hit a break inside our loop,
Unwrapping Optionals revealed the truth.
Our switch had cases, both love and woe,
With no default, we let it go.
The try and catch in our love’s domain,
Recommended by LinkedIn
We Handled joy, yet couldn’t manage pain.
Though throw did I, my heart and will,
Our love returned as nil.
I once was your delegate, you my @protocol,
In life’s grand scheme, that seemed so small.
Now, unowned feelings, like IBActions, break,
As I return to life, my soul is at stake.
I leave with a commit, a final push,
Our storyboard ends in a silent hush.
Though it’s fatalError, hard to debug or trace,
I exit(0), leaving an empty space.
Still, I import UIKit in dreams each night,
Wishing for the code to make it right.
Yet in the console of my mind, I see,
You’re an archived project, a love that used to be.
import UIKit
//ImportUI Algorithm
enum RelationshipStatus {
case together
case drifting
case apart
}
class LoveViewController: UIViewController {
@IBOutlet weak var relationshipLabel: UILabel!
var loveStatus: RelationshipStatus = .together {
didSet {
updateUI()
}
}
func updateUI() {
switch loveStatus {
case .together:
relationshipLabel.text = "Together: IBOutlet binding us."
case .drifting:
relationshipLabel.text = "Drifting: Breaking the strong reference."
case .apart:
relationshipLabel.text = "Apart: Deinitialized and memories released."
}
}
@IBAction func deinitLove(_ sender: UIButton) {
loveStatus = .apart
}
@IBAction func driftApart(_ sender: UIButton) {
loveStatus = .drifting
}
@IBAction func stayTogether(_ sender: UIButton) {
loveStatus = .together
}
func commit() {
// Commit to love
print("Committing to love.")
}
func push() {
print("Pushing the love forward.")
}
deinit {
print("Deinitializing the LoveViewController. Love Status: \(loveStatus)")
}
override func viewDidLoad() {
super.viewDidLoad()
updateUI()
}
}
do {
let loveController = LoveViewController()
loveController.stayTogether(UIButton())
try loveController.commit()
loveController.driftApart(UIButton())
try loveController.push()
loveController.deinitLove(UIButton())
print("Love is like an optional: sometimes it's nil.")
} catch {
print("An error occurred: \(error)")
}