Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Weak, Strong, Unowned - Hector Matos
Search
Realm
August 03, 2015
49k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Weak, Strong, Unowned - Hector Matos
Realm
August 03, 2015
Transcript
28 slides
Weak, Strong, Unowned Oh, My!
Quick Intro
Hi! I'm Hector Matos
None
Sr. Software Engineer @ Capital One
@allonsykraken on the Twitters
Father of KrakenDev.io
ARC
- (void)releaseTheKraken { Kraken *kraken = [[Kraken alloc] init]; //+1
retain [kraken release]; //generated by ARC }
Magic has it's limitations And so does ARC
Leaked Memory & Retain Cycles
None
None
Strong References Default in Swift
Now Stop, Example Time //Kraken holds a strong reference to
the yummy human. class Kraken { var yummyHuman: Human }
// The animation closure holds a strong reference to self
// self.retainCount is 1 here UIView.animateWithDuration(0.3) { // self.retainCount is 2 here self.view.alpha = 0.0 }
Questions?
Weak References Safe - Independent
Stop, Collaborate, & Listen! (to my next example) class KrakensFace:
UIView { @IBOutlet weak var razorSharpTeeth: UIView! } KrakenAPI.eat(yummyHuman, whenFinished: { [weak self] in self?.waitForNextMealTime() })
WTF is "[weak self] in"?!
Capture Lists It's just an array. That's all it is.
There, there. It's all over now. !
KrakenAPI.eat(yummyHuman, finished: { [weak self, unowned lovedOne = yummyHuman.lovedOne] in
self?.waitForNextMealTime() })
Questions?
Unowned References Mutual Dependence
class Human { var heart: ! func seeKrakenComing() { heart.haveHeartAttack()
} } class !: Organ { unowned let human: Human init(human: Human) { self.human = human } func haveHeartAttack() { human.die() } } let human = Human() human.heart = !(human: human)
Questions?
None
❤
More Decks by Realm
See All by Realm
WWDC 2017 Review
realm
0
2.2k
Xcode shortcuts
realm
0
4.8k
Self Branding with GitHub
realm
0
4.4k
Realm Mobile Platform overview and demo
realm
0
2.1k
Realm advanced topics and demo
realm
0
2.1k
Realm introduction Seoul meetup 10
realm
0
2.2k
Stuart Hall: How I got 2.3 Million App Downloads
realm
0
2k
James Majors: What the Swiftly Func?
realm
1
4.3k
Simina Pasat: Continuous everything for iOS apps
realm
0
680
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
610
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
WENDY [Excerpt]
tessaabrams
15
41k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
KATA
mclloyd
PRO
35
16k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
970
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
410