Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Safer Objective-C
Search
Błażej Biesiada
January 27, 2014
Programming
0
120
Safer Objective-C
Few tips on how to make your Objective-C code safer at compile time.
Błażej Biesiada
January 27, 2014
Tweet
Share
More Decks by Błażej Biesiada
See All by Błażej Biesiada
Objective-C Runtime Hacking
bejo
1
450
Other Decks in Programming
See All in Programming
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
0
890
Snowflakeで眠ったデータを起こそう!
estie
0
120
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
490
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
140
Hanami and htmx
bkuhlmann
0
210
Blue/Greenデプロイの導入による 運用フローの改善
kudoas
1
370
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
230
if constexpr文はテンプレート世界のラムダ式である
faithandbrave
3
640
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
320
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
690
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
educure_カリキュラム生操作マニュアル.pdf
linew_official
0
760
Featured
See All Featured
Practical Orchestrator
shlominoach
182
9.7k
Happy Clients
brianwarren
92
6.4k
[RailsConf 2023] Rails as a piece of cake
palkan
23
3.9k
Designing with Data
zakiwarfel
96
4.8k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
274
13k
How to name files
jennybc
65
93k
Building Effective Engineering Teams - LeadDev
addyosmani
28
1.8k
Agile that works and the tools we love
rasmusluckow
325
20k
Debugging Ruby Performance
tmm1
70
11k
Transcript
Safer Objective-C Błażej Biesiada @_bejo bejo
None
Compile Time Error Checking
Dynamic binding - (void)processArray:(NSArray *)array { for(id object in array)
{ [object process]; } }
“Static” binding - (void)processArray:(NSArray *)array { for(MyObject *object in array)
{ [object process]; } }
Key Paths [object addObserver:self forKeyPath:@"processed" options:0 context:nil];
libextobjc The Extended Objective-C library ! github.com/jspahrsummers/libextobjc
Safer Key Paths [object addObserver:self forKeyPath:@keypath(object.processed) options:0 context:nil];
Selectors [nc addObserver:self selector:@selector(process:) name:@"MyNotification" object:nil];
Safer Selectors [nc addObserver:self selector:@checkselector(self, process:) name:@"MyNotification" object:nil];
Safety first!
Compiler flags - Wall - Wextra - Werror - Wno-unused-parameter
Clang Static Analyzer
Runtime safety
NSNull NSDictionary *dict; dict = @{@"key" : [NSNull null]}; !
id val = dict[@"key"]; [val description];
Safer NSNull NSDictionary *dict; dict = @{@"key" : [EXTNil null]};
! id val = dict[@"key"]; [val description];
Thanks and see you at CocoaHeads Kraków! www.meetup.com/CocoaHeads-Krakow