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
Objective-C Programming Guide for Open Source S...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yosuke Ishikawa
February 01, 2014
Technology
9.5k
31
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Objective-C Programming Guide for Open Source Software
2014/02/01 @ GREE
Yosuke Ishikawa
February 01, 2014
More Decks by Yosuke Ishikawa
See All by Yosuke Ishikawa
効率的な開発手段として VRTを活用する
ishkawa
1
250
アプリを起動せずにアプリを開発して品質と生産性を上げる
ishkawa
0
4.6k
Achieving Testability in Presentation Layer
ishkawa
4
3.9k
Introducing Wire: Dependency Injection by Code Generator
ishkawa
12
1.4k
Declarative UICollectionView
ishkawa
28
8.5k
Nuxt.jsが掲げる"Universal Vue.js Applications"とは何者か
ishkawa
10
2.8k
Static Dependency Injection by Code Generation
ishkawa
15
6.8k
実践クライアントサイドSwift
ishkawa
23
4.4k
JSON-RPC on APIKit
ishkawa
5
68k
Other Decks in Technology
See All in Technology
LLMにもCAP定理があるという話
harukasakihara
0
320
LayerXにおけるセキュリティ管理の現在地と次の一手
tosho
0
110
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
920
非エンジニアがClaudeと挑んだ「1ヶ月間プロダクト30本ノック」
askokc
0
430
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
270
SONiC Scale-Up Working Group から探る Scale-UpやUltraEthernet機能の実装方法
ebiken
PRO
2
220
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
140
脆弱性対応、どこで線を引くか
rymiyamoto
1
380
Chainlitで作るお手軽チャットUI
ynt0485
0
230
手塩にかけりゃいいってもんじゃない
ming_ayami
0
550
機械学習を「社会実装」するということ 2026年夏版 / Social Implementation of Machine Learning June 2026 Version
moepy_stats
5
1.8k
How Timee Delivers Day 1 Production Ready LLM Features
tomoyks
0
190
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
610
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
770
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
210
The untapped power of vector embeddings
frankvandijk
2
1.8k
How to Talk to Developers About Accessibility
jct
2
230
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Fireside Chat
paigeccino
42
3.9k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Transcript
ެ։༻ͷObjective-Cͷॻ͖ํ @_ishkawa
ࣗݾհ
None
GHFeed
IS ISDiskCache ISMemoryCache ISHTTPOperation ISRemoveNull ISPersistentStack ISMethodSwizzling ISBackGesture ISRefreshControl ISColumnsController
ISRevealController ISCyclicPagesView ISFakeInterfaceOrientation ISInteractiveEdgesNavigationBar ISAlternativeRefreshControl
None
8 Pods 551 Stars
τʔΫ֓ཁ
“ެ։༻” | | ଞਓ͏ίʔυ
͔ࣗ͠৮Δ͜ͱͷͳ͍ΞϓϦͷ ίʔυ͖ͳΑ͏ʹॻ͚͍͍ (ࣗݾͰ)
͔͠͠ɺଞਓ৮ΔՄೳੑ͕͋Δ߹
✓ ୭Ͱ؆୯ʹಋೖͰ͖Δ ✓ ୭Ͱਖ਼͘͠ѻ͏͜ͱ͕Ͱ͖Δ ✓ ଞͷίʔυͷ෭࡞༻͕ͳ͍ ✓ γϯϘϧϦιʔε͕িಥ͠ͳ͍ ͱ͍ͬͨ͜ͱ͕ٻΊΒΕΔͷͰɺࠓͦͷΛ͠·͢ɻ
1.ΞϓϦͱͷিಥ 2.ྑ͍@interface 3.Ϣχοτςετ τʔΫ֓ཁ
1.ΞϓϦͱͷিಥ
2छྨͷিಥ ✗ γϯϘϧͷিಥ ✗ Ϧιʔεͷিಥ
1.1.γϯϘϧͷিಥ
✗ Ϋϥεͷিಥ ✗ ΧςΰϦͷϝιουͷিಥ ✗ ఆͷিಥ
Duplicated Symbol !!!
None
γϯϘϧͷিಥ໋໊نଇͰ͙͜ͱ͕Ͱ͖Δ ʢେͷ߹ʣ
1.1.1.Ϋϥεͷ໋໊نଇ
✓ 3จࣈͷେจࣈprefixΛ͚ͭΔ @interface ISHObject : NSObject ! @end
Objective-CʹΑΔϓϩάϥϛϯά (p.127) “ಠࣗͷΫϥεʹ3จࣈͷϓϨϑΟοΫεΛ͚͍ͭͯͩ͘͞ɻ ձ໊ࣾ ΞϓϦέʔγϣϯ໊ʹͪͳΜͩͷͰɺॏཁͳίϯϙʔωϯτʹ ༝དྷ͢ΔͷͰߏ͍·ͤΜɻ” “ͨͱ͑ɺձ໊͕ࣾWhispering Oakɺ։ൃ͢ΔήʔϜͷ໊લ͕Zebra SurpriseͰ͋Εɺ WZSWOZͱ͍ͬͨϓϨϑΟοΫεʹ͢ΔͱΑ͍
͔͠Ε·ͤΜɻ”
Objective-CʹΑΔϓϩάϥϛϯά (p.126) “2จࣈͷϓϨϑΟοΫεɺϑϨʔϜϫʔΫΫϥεʹ͏ͨΊɺ Apple͕༧͍ͯ͠·͢ɻ” ✗ IS ✓ NJK
1.1.2.ΧςΰϦͷϝιουͷ໋໊نଇ
✓ 3จࣈͷখจࣈprefixΛ͚ͭΔ @interface NSObject (ISHAdditions) ! - (void)ish_additionalMethod; ! @end
Objective-CʹΑΔϓϩάϥϛϯά (p.74) “Ϋϥε໊ͷϓϨϑΟοΫεͱಉ͡3จࣈͷจࣈྻΛɺϝιου໊ ͷنʹैͬͯখจࣈʹ͠ɺΞϯμʔείΞΛ͞ΜͰϝιου ໊ͱ࿈͍݁ͯͩ͘͠͞ɻ” “ಈ࡞͕ෆఆʹͳΔ͜ͱΛճආ͢ΔͨΊɺϑϨʔϜϫʔΫΫϥε ʹΧςΰϦΛఆٛͯ͠ϝιουΛՃ ͢Δࡍɺ໊લʹϓϨ ϑΟοΫεΛ͚ͭΔΑ͏ʹ͢ΔͱΑ͍Ͱ͠ΐ͏ɻ”
App Library methodA methodA ͲͪΒͷmethodAͷ࣮͕࣮ߦ͞ΕΔͷ͔ෆఆ
App Library methodA ish_methodA
1.1.3.ఆͷ໋໊نଇ
✓ ؔ࿈͢ΔΫϥε໊Λ಄ʹ͚ͭΔ extern NSString *const ISHObjectGlobalConstant; ! @interface ISHObject :
NSObject ! @end ISHObject.h ISHObject.m NSString *const ISHObjectGlobalConstant = @"Foo"; ! @implementation ISHObject ! @end
✓ ֎෦͔Βෆཁͳఆඇެ։ʹ͢Δ ISHObject.m static NSString *const ISHLocalConstant = @"Foo"; !
@implementation ISHObject ! @end
1.1.4.Α͋͘ΔγϯϘϧͷিಥ
ϥΠϒϥϦ͕ґଘ͢ΔϥΠϒϥϦ͕2ॏʹϏϧυλʔήοτʹՃ͞Ε͍ͯΔ Library A Library B Library C Library C
ϥΠϒϥϦ͕ϥΠϒϥϦʹґଘ͢Δ͜ͱѱ͍͜ͱͰ ͳ͍͕ɺར༻ଆͰিಥ͕ى͖ͳ͍Α͏ʹཹҙ͢Δ͖
✓ ֎෦ͷϥΠϒϥϦʹґଘ͢Δ͜ͱΛ໌ه͢Δ ✓ CocoaPodsͳͲͷґଘཧΛਪ͢Δ
None
1.1.Ϧιʔεͷিಥ
దʹϥΠϒϥϦͷϦιʔεΛѻ͏ͱ ར༻͢ΔΞϓϦͷϦιʔεͱিಥ͢Δ
[UIImage imageNamed:@"Foo"]; NSLocalizedString(@"Foo", nil);
NSBundle *bundle = [NSBundle mainBundle]; NSString *filePath = [bundle pathForResource:@"foo"
ofType:@"png"]; [UIImage imageWithContentsOfFile:filePath]; NSBundle *bundle = [NSBundle mainBundle]; [bundle localizedStringForKey:@"foo" value:@"" table:nil]; ϝΠϯόϯυϧͷϦιʔεΛಡΜͰ͍Δ
main bundle foo.png foo.png foo.pngmain bundleʹ1ݸ͔͠ଘࡏͰ͖ͳ͍ ? App Library
Main bundle foo.png foo.png ϥΠϒϥϦ༻ʹbundleΛͭ͘Εղܾ Library bundle
✓ ϝΠϯόϯυϧʹΞΫηε͢Δͷʹҙ ✓ ϦιʔεϥΠϒϥϦઐ༻ͷNSBundleʹೖΕΔ
None
2.ྑ͍ @Interface
✓ Θ͔Γ͍͢
✓ ࣮ΛਪଌͰ͖Δ ✓ ޡ༻Λͤ͞ͳ͍
@interface ISHCache : NSObject ! @property (nonatomic) NSUInteger size; @property
(nonatomic) NSUInteger limit; ! - (id)get:(id)key; - (void)set:(id)object key:(id)key; - (void)remove:(id)key; - (void)removeAll; ! @end ✗
@interface ISHCache : NSObject ! @property (nonatomic, readonly) NSUInteger currentSize;
@property (nonatomic, readwrite) NSUInteger sizeLimit; ! - (id)objectForKey:(id)key; - (void)setObject:(id)object forKey:(id)key; - (void)removeObjectForKey:(id)key; - (void)removeAllObjects; ! @end ✓
✓ ྑ͍ @property ✓ ྑ͍௨ύλʔϯ τϐοΫແݶ͋Δ͕ಛʹॏཁͳ2ͭ
2.1.ྑ͍ @property
✓ มߋͷՄ൱Λ໌֬ʹ͢Δ ✓ ϥΠϒϥϦͷར༻ʹඞཁͳใ༩͑Δ ✓ ϥΠϒϥϦͷར༻ʹෆཁͳใΛ༩͑ͳ͍
1.1.3.readwrite vs readonly
readwrite ✓ มߋ͢Δඞཁ͕͋ΔϓϩύςΟ
readwrite ͍͔ͳΔλΠϛϯάʹมߋ͞Εͯ ΦϒδΣΫτͷ߹ੑΛอͯΔ͜ͱ͕·͍͠
ྫ
@interface ISHCache : NSObject ! @property (nonatomic, readonly) NSUInteger currentSize;
@property (nonatomic, readwrite) NSUInteger sizeLimit; ! - (id)objectForKey:(id)key; - (void)setObject:(id)object forKey:(id)key; - (void)removeObjectForKey:(id)key; - (void)removeAllObjects; ! @end currentSize < sizeLimit
- (void)setSizeLimit:(NSUInteger)sizeLimit { _sizeLimit = sizeLimit; ! if (self.currentSize >
sizeLimit) { [self removeAllObjects]; } } currentSize < sizeLimit ΛอͭͨΊʹ͜ͷΑ͏ͳ࣮͕ظ͞ΕΔ NSCache͜͏͍͏ڍಈʹͳ͍ͬͯΔ
readwrite ͍͔ͳΔλΠϛϯάʹมߋ͞Εͯ ΦϒδΣΫτͷ߹ੑΛอͯΔ͜ͱ͕·͍͠
͜͏͍࣮͕ͬͨ໘Ͱɺ ͦͦมߋ͢Δඞཁͳ͍߹?
readonly ✓ มߋ͢Δඞཁ͕ͳ͍ϓϩύςΟ ✓ มߋΛېࢭ͍ͨ͠ϓϩύςΟ
readonly มߋΛؾʹ͠ͳͯ͘ࡁΉ
ྫ
@interface ISHCache : NSObject ! @property (nonatomic, readonly) NSUInteger currentSize;
@property (nonatomic, readonly) NSUInteger sizeLimit; ! - (instancetype)initWithSizeLimit:(NSUInteger)sizeLimit; ! - (id)objectForKey:(id)key; - (void)setObject:(id)object forKey:(id)key; - (void)removeObjectForKey:(id)key; - (void)removeAllObjects; ! @end
- (instancetype)initWithSizeLimit:(NSUInteger)sizeLimit { self = [super init]; if (self) {
_sizeLimit = sizeLimit; } return self; } มߋͰ͖ͳ͍ΘΓʹॳظԽ࣌ʹΛ͢
·ͱΊΔͱ
readwrite ✓ มߋ͢Δඞཁ͕͋ΔϓϩύςΟ ✓ มߋ͞Εͯ߹ੑ͕อͨΕΔ readonly ✓ มߋ͢Δඞཁ͕ͳ͍ϓϩύςΟ ✓ มߋΛېࢭ͍ͨ͠ϓϩύςΟ
None
2.2.ྑ͍௨ύλʔϯ
✓ blocks ✓ delegate ✓ NSNotification ✓ KVO
2.2.1.blocks
✓ ௨͕ಛఆͷϝιουʹ݁ͼͭ͘ ✓ ௨ͷछྨ͕গͳ͍߹ ద͍ͯ͠Δέʔε UIDocument *document; [document openWithCompletionHandler:^(BOOL success)
{ // completed }];
✓ Ҿʹ݁ՌΛ͢ ✓ Τϥʔ͕ఆ͞ΕΔ߹NSError͢ ࡞๏ GKTurnBasedMatch *match; [match acceptInviteWithCompletionHandler:^(GKTurnBasedMatch *match,
NSError *error) { ; }];
blocksͷߏจҟ༷ʹෳࡶ
None
✓ http://fuckingblocksyntax.com ✓ Ѫ͕͋Εͳ͍
2.2.2.delegate
✓ ௨͕ಛఆͷΦϒδΣΫτʹ݁ͼͭ͘ ✓ ௨ͷछྨ͕ଟ͍ ✓ ௨ͷड͚ख͕1͔ͭ͠ͳ͍ ద͍ͯ͠Δέʔε @optional ! -
(void)scrollViewDidScroll:(UIScrollView *)scrollView; - (void)scrollViewDidZoom:(UIScrollView *)scrollView; - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView; - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView; ໋໊نଇʹ͍ͭͯCocoa͚ίʔσΟϯάΨΠυϥΠϯ, p.15Λࢀর
2.2.3.NSNotification
✓ ௨ͷड͚ख͕ଟ͍ ✓ ௨ͷૹ৴ݩͱड͚ख͕ԕ͍ͱ͖ ద͍ͯ͠Δέʔε άϩʔόϧͳ௨ʹͳΔͷͰ҆қʹ࠾༻ͤͣɺ ઌʹdelegate, BlocksͰ࣮ݱͰ͖ͳ͍͔ݕ౼͢Δɻ
2.3.ྑ͍@interface·ͱΊ
✓ దࡐదॴ readwrite readonly ✓ blocks ✓ delegate ✓ NSNotification
✓ KVO
None
3.Ϣχοτςετ
3.1.ςετΛॻ͘ཧ༝
ςετΛॻ͍ͨํ͕։ൃ͕͍Օॴ͕͋Δ (σϞΞϓϦͰσόοά͢ΔΑΓ)
@interface ISHCache : NSObject ! @property (nonatomic, readonly) NSUInteger currentSize;
@property (nonatomic, readwrite) NSUInteger sizeLimit; ! - (id)objectForKey:(id)key; - (void)setObject:(id)object forKey:(id)key; - (void)removeObjectForKey:(id)key; - (void)removeAllObjects; ! @end
- (void)testSetObjectForKey { id object = [[NSObject alloc] init]; id
key = @"foo"; ! [cache setObject:object forKey:key]; ! XCTAssertEqual(cache.currentSize, 1U); XCTAssertEqualObjects([cache objectForKey:key], object); }
✓ setObject:forKey:ͷ࣮ߦ࣌ʹsizeLimitΛ͑Δ߹ʁ ✓ setObject:forKey:ͷ࣮ߦޙʹsizeLimitΛখͨ͘͞͠߹ʁ ✓ removeAllObjectsͷ࣮ߦޙͷcurrentSizeʁ ͱ͍͏݅ΛσϞΞϓϦ্Ͱຖճσόοά͢ΔඇৗʹͭΒ͍͕ɺ Ϣχοτςετ1ॻ͚܁Γฦ࣮͠ߦͰ͖Δɻ
ίʔυ͕յΕ͍ͯΔ͜ͱΛ͙͢ʹൃݟͰ͖Δ ظʹΘͨͬͯෳਓ͕ϝϯςφϯε͢ΔϓϩάϥϜյΕ͍͢ ςετϓϩάϥϜ͕ਖ਼͍͜͠ͱͷূ໌Ͱͳ͍
✓ setObject:forKey:ͷ࣮ߦ࣌ʹsizeLimitΛ͑Δ߹ʁ ✓ setObject:forKey:ͷ࣮ߦޙʹsizeLimitΛখͨ͘͞͠߹ʁ ✓ removeAllObjectsͷ࣮ߦޙͷcurrentSizeʁ ͲΕ͔1͚ͭͩյΕͨ͜ͱΛσϞΞϓϦ্Ͱ ݕ͢Δ͜ͱ͍͕͠ɺϢχοτςετͳΒ؆୯
ϥΠϒϥϦͷςετͷϝϦοτ ίετʹݟ߹͏͜ͱ͕ଟ͍ ΞϓϦͱൺ༷ͯมߋ͕͘͢ͳ͍ͷͰɺ ςετίʔυ͕ΰϛʹͳΔ͕͍֬
ϥΠϒϥϦʹର͢ΔϢχοτςετΛॻ͘ཧ༝े
3.2.CIΛಋೖ͢Δ
͔ͤͬ͘ςετΛॻ͍ͨͷͰ࣮֬ʹ࣮ߦ͍ͨ͠ git pushͷલʹඞͣςετΛ࣮ߦͰ͖Δਓؒগͳ͍
Git repository CI server Developer git push git hook Build
report CI
git push͢ΔͱΕͳ͘Ϩϙʔτ͕Β͑ΔΈ ✓ ϏϧυͰ͖Δ͔ʁ ✓ ςετ௨͔ͬͨʁ ✓ ίʔυΧόϨοδʁ
3.2.1.CIͷηοτΞοϓ
࠷ϧʔτ: λʔϛφϧ͔ΒϏϧυͰ͖ΔΑ͏ʹ
xcodebuild clean test \ -sdk iphonesimulator \ -workspace ISDiskCache.xcworkspace \
-scheme ISDiskCache \ -configuration Debug \ -destination "name=iPhone Retina (4-inch),OS=7.0" ཁ͢ΔʹΫϦʔϯͯ͠ςετͯ͠ͶͬͯίϚϯυ ͋ͱ͜ΕΛCIαʔόʔʹ͑Δ͚ͩͰOK
3.2.2.WebαʔϏε
CI αʔϏε
Git repository CI server Developer git push git hook Build
report
GitHub Developer git push git hook Build report
✓ public repositoryແྉ ✓ GitHub࿈ܞ ✓ status badge
֘ίϛοτͷϏϧυͷঢ়ଶ͕Θ͔Δ !!!
ίʔυΧόϨοδදࣔαʔϏε
֘ίϛοτͷίʔυΧόϨοδ͕Θ͔Δ
GitHub Developer git push git hook Build report Coverage report
✓ public repositoryແྉ ✓ GitHub࿈ܞ ✓ status badge
྆ํηοτΞοϓ͢Δͱ͜Μͳײ͡
https://github.com/ishkawa/ISDiskCache/
3.3.Ϣχοτςετ·ͱΊ
✓ ςετͷಋೖͰ։ൃ͕͘ͳΔՕॴ͋Δ ✓ յΕͨՕॴΛൃݟ͘͢͠ͳΔ ✓ ϥΠϒϥϦͷςετΞϓϦͷςετΑΓߴCP ✓ CIͰৗʹςετ͞Εͨঢ়ଶΛอͭ͜ͱ͕Ͱ͖Δ
None
·ͱΊ
1.ಋೖઌͷΞϓϦͱͷিಥʹؾΛ͚ͭΔ 2.ଞਓʹΘ͔Γ͍͢ΠϯλʔϑΣʔεʹ͢Δ 3.࣭͕མͪʹ͍͘ΈΛಋೖ͢Δ ϥΠϒϥϦΛެ։͢Δͱ͖….