Skip to content

Instantly share code, notes, and snippets.

View SheldonWangRJT's full-sized avatar
🎯
Focusing

Engineer Sheldon Wang SheldonWangRJT

🎯
Focusing
View GitHub Profile
@SheldonWangRJT
SheldonWangRJT / What Does "weak" Exactly Do in iOS.md
Last active August 5, 2018 02:26
What Does "weak" Exactly Do in iOS?

What Does "weak" Exactly Do in iOS?

#iOSBySheldon

As we all know making an property weak is a good way to solve retain cycle or strong reference cycle. But do you know what does weak key-word exactly do behind the scene?

Two Quick Challenging Questions

  • Why weak property is nil after its owner object is released?
  • What exactly happened after weak property's owner object released?
@SheldonWangRJT
SheldonWangRJT / How Does Apple Realize KVO?.md
Last active August 5, 2018 04:44
How Does Apple Realize KVO?

How Does Apple Realize KVO?

#iOSBySheldon

As you may all know KVO stands for key-value observing. It is a mechanism you can use to do the reactive programming. I have posted a video about how to use KVO + KVC for reactive programming here, please don't hesitate to check it out. I will give you an good example of using KVO. Suppose you have a downloading progress value coming, Float for example. You have to update your UIProgressBar with that value. A good way to achieve this might be let your UIProgressBar observe that Float value and whenever that float value changed, you change your UIProgressBar.value accordingly. Again, please feel free to check my video tutorial about that as well as the finished project here in Github.

How does Apple realize this?

Per Apple's document, "Automatic key-value observing is implemented using a technique called isa-swizzling… When an observer is registered for an attribute of an object the isa pointer of the observed object is modified, pointing to an intermedia

@SheldonWangRJT
SheldonWangRJT / iOS - What does SiriKit do? How to use it in our app?
Created March 18, 2018 00:09
iOS - What does SiriKit do? How to use it in our app?
#iOSBySheldon
As Siri became more and more popular, people won't be satisfied to only use Siri in the iOS system level, instead, it will be much better if we can use Siri with apps that are not only from Apple. In WWDC 2016, Apple finally opened SiriKit to the developers. Time flies, it is almost two years past. I do believe in this year's WWDC 2018, Apple will give a big enhancement on the SiriKit. One of the bigger reason might be the release of the HomePod.
In this post, I don't want to show you any code, but I do want to explain to you guys what does SiriKit do and the basics of SiriKit.Same as Alex for Amazon and "OK Google", SiriKit uses a technique called Natural Language Processing.
If you check the link from WikiPedia, you will be find the following definition:"Natural-language processing (NLP) is an area of computer science and artificial intelligence concerned with the interactions between computers and human (natural) languages, in particular how to program computers to fruitfully process larg
@SheldonWangRJT
SheldonWangRJT / Git - How to Rebase and Squash Commits
Created March 24, 2018 00:23
Git - How to Rebase and Squash Commits
Git - Rebase and Squashing
#iOSBySheldon
It is pretty often that you notice your feature branch has way too many commits right be fore you merge to the Master branch.
If you see your git history of your branch, it might be like:
History:
Commit xxxx1 "modified 2 more tests"
Commit xxxx2 "updated first test"
@SheldonWangRJT
SheldonWangRJT / Keychain - local items alert
Created March 24, 2018 14:47
How to solve mac app wants to use the "Local Items" keychain endlessly
#iOSBySheldon
Sometimes due to Mac system error, you are seeing this alert a lot. This alert could be shown repleatedly and annoyingly.
--------------------------------------------------
| xxx wants to use the "Local Items" keychain. |
| Please enter the keychain password. |
| Password: ________________________ |
--------------------------------------------------
We can clean our KeyChain "Local Items" using Terminal to solve this issue.
@SheldonWangRJT
SheldonWangRJT / iOS Most Useful Debug Tricks
Created March 30, 2018 02:25
iOS Most Useful Debug Tricks
1. objc_exception_throw
When breakpoint auto landed on the assembly page, try to type
(lldb) po $arg1
(lldb) po [$arg1 name]
(lldb) po [$arg1 reason]
This may bring extra info, like "xxx is nil"
[1.1] https://stackoverflow.com/questions/3327828/xcode-lldb-how-to-get-information-about-an-exception-that-was-just-thrown
[1.2] https://www.natashatherobot.com/xcode-debugging-trick/
2. Double click break point to set break conditions & additional actions
@SheldonWangRJT
SheldonWangRJT / .bash_profile
Created May 16, 2018 17:37
My Bash Profile
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export PS1="\w 🤡 🤡 🤡 : "
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
@SheldonWangRJT
SheldonWangRJT / WWDC18-416.md
Last active April 11, 2021 09:45
WWDC18 Notes by Sheldon - Session 416 - iOS Memory Deep Dive

WWDC18 Notes - Session 416 - iOS Memory Deep Dive

All session list link: Here
Session Link: Here
Demo starts @ 25:30 in the video.
Download session slides: Here

This notes is written by Sheldon after watching WWDC18 session 416. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

@SheldonWangRJT
SheldonWangRJT / WWDC18-412-Notes-Sheldon.md
Last active July 12, 2018 15:30
WWDC18 Notes by Sheldon - Session 412 - iOS Advanced Debugging with LLDB

WWDC18 Notes - Session 412 - Advanced Debugging with Xcode and LLDB

All session list link: Here
Session Link: Here
Download session slides: Here

This notes is written by Sheldon after watching WWDC18 session 412. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Quick Tab for Breakpoint

@SheldonWangRJT
SheldonWangRJT / WWDC18-234-Notes-Sheldon.md
Last active July 12, 2018 16:20
WWDC18 Notes by Sheldon - Session 234 - Safari and WebKit

WWDC18 Notes - Session 234 - Safari and WebKit

All session list link: Here
Session Link: Here
Download session slides: Here
More about AR file .usdz is Here

This notes is written by Sheldon after watching WWDC18 session 234. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.