Slide 1

Slide 1 text

ެ։༻ͷObjective-Cͷॻ͖ํ @_ishkawa

Slide 2

Slide 2 text

ࣗݾ঺հ

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

GHFeed

Slide 5

Slide 5 text

IS ISDiskCache ISMemoryCache ISHTTPOperation ISRemoveNull ISPersistentStack ISMethodSwizzling ISBackGesture ISRefreshControl ISColumnsController ISRevealController ISCyclicPagesView ISFakeInterfaceOrientation ISInteractiveEdgesNavigationBar ISAlternativeRefreshControl

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

8 Pods 551 Stars

Slide 8

Slide 8 text

τʔΫ֓ཁ

Slide 9

Slide 9 text

“ެ։༻” | | ଞਓ΋࢖͏ίʔυ

Slide 10

Slide 10 text

ࣗ෼͔͠৮Δ͜ͱͷͳ͍ΞϓϦͷ ίʔυ͸޷͖ͳΑ͏ʹॻ͚͹͍͍ (ࣗݾ੹೚Ͱ)

Slide 11

Slide 11 text

͔͠͠ɺଞਓ΋৮ΔՄೳੑ͕͋Δ৔߹͸

Slide 12

Slide 12 text

✓ ୭Ͱ΋؆୯ʹಋೖͰ͖Δ ✓ ୭Ͱ΋ਖ਼͘͠ѻ͏͜ͱ͕Ͱ͖Δ ✓ ଞͷίʔυ΁ͷ෭࡞༻͕ͳ͍ ✓ γϯϘϧ΍Ϧιʔε͕িಥ͠ͳ͍ ͱ͍ͬͨ͜ͱ͕ٻΊΒΕΔͷͰɺࠓ೔͸ͦͷ࿩Λ͠·͢ɻ

Slide 13

Slide 13 text

1.ΞϓϦͱͷিಥ 2.ྑ͍@interface 3.Ϣχοτςετ τʔΫ֓ཁ

Slide 14

Slide 14 text

1.ΞϓϦͱͷিಥ

Slide 15

Slide 15 text

2छྨͷিಥ ✗ γϯϘϧͷিಥ ✗ Ϧιʔεͷিಥ

Slide 16

Slide 16 text

1.1.γϯϘϧͷিಥ

Slide 17

Slide 17 text

✗ Ϋϥεͷিಥ ✗ ΧςΰϦͷϝιουͷিಥ ✗ ఆ਺ͷিಥ

Slide 18

Slide 18 text

Duplicated Symbol !!!

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

γϯϘϧͷিಥ͸໋໊نଇͰ๷͙͜ͱ͕Ͱ͖Δ ʢେ఍ͷ৔߹ʣ

Slide 21

Slide 21 text

1.1.1.Ϋϥεͷ໋໊نଇ

Slide 22

Slide 22 text

✓ 3จࣈͷେจࣈprefixΛ͚ͭΔ @interface ISHObject : NSObject ! @end

Slide 23

Slide 23 text

Objective-CʹΑΔϓϩάϥϛϯά (p.127) “ಠࣗͷΫϥεʹ͸3จࣈͷϓϨϑΟοΫεΛ͚͍ͭͯͩ͘͞ɻ ձ໊ࣾ ΍ΞϓϦέʔγϣϯ໊ʹͪͳΜͩ΋ͷͰ΋ɺॏཁͳίϯϙʔωϯτʹ ༝དྷ͢Δ΋ͷͰ΋ߏ͍·ͤΜɻ” “ͨͱ͑͹ɺձ໊͕ࣾWhispering Oakɺ։ൃ͢ΔήʔϜͷ໊લ͕Zebra SurpriseͰ͋Ε͹ɺ WZS΍WOZͱ͍ͬͨϓϨϑΟοΫεʹ͢ΔͱΑ͍ ͔΋͠Ε·ͤΜɻ”

Slide 24

Slide 24 text

Objective-CʹΑΔϓϩάϥϛϯά (p.126) “2จࣈͷϓϨϑΟοΫε͸ɺϑϨʔϜϫʔΫΫϥεʹ࢖͏ͨΊɺ Apple͕༧໿͍ͯ͠·͢ɻ” ✗ IS ✓ NJK

Slide 25

Slide 25 text

1.1.2.ΧςΰϦͷϝιουͷ໋໊نଇ

Slide 26

Slide 26 text

✓ 3จࣈͷখจࣈprefixΛ͚ͭΔ @interface NSObject (ISHAdditions) ! - (void)ish_additionalMethod; ! @end

Slide 27

Slide 27 text

Objective-CʹΑΔϓϩάϥϛϯά (p.74) “Ϋϥε໊ͷϓϨϑΟοΫεͱಉ͡3จࣈͷจࣈྻΛɺϝιου໊ ͷن໿ʹैͬͯখจࣈʹ͠ɺΞϯμʔείΞΛ͸͞ΜͰϝιου ໊ͱ࿈͍݁ͯͩ͘͠͞ɻ” “ಈ࡞͕ෆఆʹͳΔ͜ͱΛճආ͢ΔͨΊɺϑϨʔϜϫʔΫΫϥε ʹΧςΰϦΛఆٛͯ͠ϝιουΛ௥Ճ ͢Δࡍ͸ɺ໊લʹϓϨ ϑΟοΫεΛ͚ͭΔΑ͏ʹ͢ΔͱΑ͍Ͱ͠ΐ͏ɻ”

Slide 28

Slide 28 text

App Library methodA methodA ͲͪΒͷmethodAͷ࣮૷͕࣮ߦ͞ΕΔͷ͔ෆఆ

Slide 29

Slide 29 text

App Library methodA ish_methodA

Slide 30

Slide 30 text

1.1.3.ఆ਺ͷ໋໊نଇ

Slide 31

Slide 31 text

✓ ؔ࿈͢ΔΫϥε໊Λ಄ʹ͚ͭΔ extern NSString *const ISHObjectGlobalConstant; ! @interface ISHObject : NSObject ! @end ISHObject.h ISHObject.m NSString *const ISHObjectGlobalConstant = @"Foo"; ! @implementation ISHObject ! @end

Slide 32

Slide 32 text

✓ ֎෦͔Βෆཁͳఆ਺͸ඇެ։ʹ͢Δ ISHObject.m static NSString *const ISHLocalConstant = @"Foo"; ! @implementation ISHObject ! @end

Slide 33

Slide 33 text

1.1.4.Α͋͘ΔγϯϘϧͷিಥ

Slide 34

Slide 34 text

ϥΠϒϥϦ͕ґଘ͢ΔϥΠϒϥϦ͕2ॏʹϏϧυλʔήοτʹ௥Ճ͞Ε͍ͯΔ Library A Library B Library C Library C

Slide 35

Slide 35 text

ϥΠϒϥϦ͕ϥΠϒϥϦʹґଘ͢Δ͜ͱѱ͍͜ͱͰ͸ ͳ͍͕ɺར༻ଆͰিಥ͕ى͖ͳ͍Α͏ʹཹҙ͢Δ΂͖

Slide 36

Slide 36 text

✓ ֎෦ͷϥΠϒϥϦʹґଘ͢Δ͜ͱΛ໌ه͢Δ ✓ CocoaPodsͳͲͷґଘ؅ཧΛਪ঑͢Δ

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

1.1.Ϧιʔεͷিಥ

Slide 39

Slide 39 text

ద౰ʹϥΠϒϥϦͷϦιʔεΛѻ͏ͱ ར༻͢ΔΞϓϦͷϦιʔεͱিಥ͢Δ

Slide 40

Slide 40 text

[UIImage imageNamed:@"Foo"]; NSLocalizedString(@"Foo", nil);

Slide 41

Slide 41 text

NSBundle *bundle = [NSBundle mainBundle]; NSString *filePath = [bundle pathForResource:@"foo" ofType:@"png"]; [UIImage imageWithContentsOfFile:filePath]; NSBundle *bundle = [NSBundle mainBundle]; [bundle localizedStringForKey:@"foo" value:@"" table:nil]; ϝΠϯόϯυϧͷϦιʔεΛಡΜͰ͍Δ

Slide 42

Slide 42 text

main bundle foo.png foo.png foo.png͸main bundleʹ1ݸ͔͠ଘࡏͰ͖ͳ͍ ? App Library

Slide 43

Slide 43 text

Main bundle foo.png foo.png ϥΠϒϥϦ༻ʹbundleΛͭ͘Ε͹ղܾ Library bundle

Slide 44

Slide 44 text

✓ ϝΠϯόϯυϧʹΞΫηε͢Δ΋ͷʹ஫ҙ ✓ Ϧιʔε͸ϥΠϒϥϦઐ༻ͷNSBundleʹೖΕΔ

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

2.ྑ͍ @Interface

Slide 47

Slide 47 text

✓ Θ͔Γ΍͍͢

Slide 48

Slide 48 text

✓ ࣮૷ΛਪଌͰ͖Δ ✓ ޡ༻Λͤ͞ͳ͍

Slide 49

Slide 49 text

@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 ✗

Slide 50

Slide 50 text

@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 ✓

Slide 51

Slide 51 text

✓ ྑ͍ @property ✓ ྑ͍௨஌ύλʔϯ τϐοΫ͸ແݶ͋Δ͕ಛʹॏཁͳ2ͭ

Slide 52

Slide 52 text

2.1.ྑ͍ @property

Slide 53

Slide 53 text

✓ มߋͷՄ൱Λ໌֬ʹ͢Δ ✓ ϥΠϒϥϦͷར༻ʹඞཁͳ৘ใ͸༩͑Δ ✓ ϥΠϒϥϦͷར༻ʹෆཁͳ৘ใΛ༩͑ͳ͍

Slide 54

Slide 54 text

1.1.3.readwrite vs readonly

Slide 55

Slide 55 text

readwrite ✓ มߋ͢Δඞཁ͕͋ΔϓϩύςΟ

Slide 56

Slide 56 text

readwrite ͍͔ͳΔλΠϛϯάʹมߋ͞Εͯ΋ ΦϒδΣΫτͷ੔߹ੑΛอͯΔ͜ͱ͕๬·͍͠

Slide 57

Slide 57 text

Slide 58

Slide 58 text

@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

Slide 59

Slide 59 text

- (void)setSizeLimit:(NSUInteger)sizeLimit { _sizeLimit = sizeLimit; ! if (self.currentSize > sizeLimit) { [self removeAllObjects]; } } currentSize < sizeLimit ΛอͭͨΊʹ͜ͷΑ͏ͳ࣮૷͕ظ଴͞ΕΔ NSCache͸͜͏͍͏ڍಈʹͳ͍ͬͯΔ

Slide 60

Slide 60 text

readwrite ͍͔ͳΔλΠϛϯάʹมߋ͞Εͯ΋ ΦϒδΣΫτͷ੔߹ੑΛอͯΔ͜ͱ͕๬·͍͠

Slide 61

Slide 61 text

͜͏͍࣮ͬͨ૷͕໘౗Ͱɺ ͦ΋ͦ΋มߋ͢Δඞཁ΋ͳ͍৔߹͸?

Slide 62

Slide 62 text

readonly ✓ มߋ͢Δඞཁ͕ͳ͍ϓϩύςΟ ✓ มߋΛېࢭ͍ͨ͠ϓϩύςΟ

Slide 63

Slide 63 text

readonly มߋΛؾʹ͠ͳͯ͘ࡁΉ

Slide 64

Slide 64 text

Slide 65

Slide 65 text

@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

Slide 66

Slide 66 text

- (instancetype)initWithSizeLimit:(NSUInteger)sizeLimit { self = [super init]; if (self) { _sizeLimit = sizeLimit; } return self; } มߋͰ͖ͳ͍୅ΘΓʹॳظԽ࣌ʹ஋Λ౉͢

Slide 67

Slide 67 text

·ͱΊΔͱ

Slide 68

Slide 68 text

readwrite ✓ มߋ͢Δඞཁ͕͋ΔϓϩύςΟ ✓ มߋ͞Εͯ΋੔߹ੑ͕อͨΕΔ readonly ✓ มߋ͢Δඞཁ͕ͳ͍ϓϩύςΟ ✓ มߋΛېࢭ͍ͨ͠ϓϩύςΟ

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

2.2.ྑ͍௨஌ύλʔϯ

Slide 71

Slide 71 text

✓ blocks ✓ delegate ✓ NSNotification ✓ KVO

Slide 72

Slide 72 text

2.2.1.blocks

Slide 73

Slide 73 text

✓ ௨஌͕ಛఆͷϝιουʹ݁ͼͭ͘ ✓ ௨஌ͷछྨ͕গͳ͍৔߹ ద͍ͯ͠Δέʔε UIDocument *document; [document openWithCompletionHandler:^(BOOL success) { // completed }];

Slide 74

Slide 74 text

✓ Ҿ਺ʹ͸݁ՌΛ౉͢ ✓ Τϥʔ͕૝ఆ͞ΕΔ৔߹͸NSError΋౉͢ ࡞๏ GKTurnBasedMatch *match; [match acceptInviteWithCompletionHandler:^(GKTurnBasedMatch *match, NSError *error) { ; }];

Slide 75

Slide 75 text

blocksͷߏจ͸ҟ༷ʹෳࡶ

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

✓ http://fuckingblocksyntax.com ✓ Ѫ͕͋Ε͹໰୊ͳ͍

Slide 78

Slide 78 text

2.2.2.delegate

Slide 79

Slide 79 text

✓ ௨஌͕ಛఆͷΦϒδΣΫτʹ݁ͼͭ͘ ✓ ௨஌ͷछྨ͕ଟ͍ ✓ ௨஌ͷड͚ख͕1͔ͭ͠ͳ͍ ద͍ͯ͠Δέʔε @optional ! - (void)scrollViewDidScroll:(UIScrollView *)scrollView; - (void)scrollViewDidZoom:(UIScrollView *)scrollView; - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView; - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView; ໋໊نଇʹ͍ͭͯ͸Cocoa޲͚ίʔσΟϯάΨΠυϥΠϯ, p.15Λࢀর

Slide 80

Slide 80 text

2.2.3.NSNotification

Slide 81

Slide 81 text

✓ ௨஌ͷड͚ख͕ଟ͍ ✓ ௨஌ͷૹ৴ݩͱड͚ख͕ԕ͍ͱ͖ ద͍ͯ͠Δέʔε άϩʔόϧͳ௨஌ʹͳΔͷͰ҆қʹ࠾༻ͤͣɺ ઌʹdelegate, BlocksͰ࣮ݱͰ͖ͳ͍͔ݕ౼͢Δɻ

Slide 82

Slide 82 text

2.3.ྑ͍@interface·ͱΊ

Slide 83

Slide 83 text

✓ దࡐదॴ readwrite readonly ✓ blocks ✓ delegate ✓ NSNotification ✓ KVO

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

3.Ϣχοτςετ

Slide 86

Slide 86 text

3.1.ςετΛॻ͘ཧ༝

Slide 87

Slide 87 text

ςετΛॻ͍ͨํ͕։ൃ͕଎͍Օॴ͕͋Δ (σϞΞϓϦͰσόοά͢ΔΑΓ΋)

Slide 88

Slide 88 text

@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

Slide 89

Slide 89 text

- (void)testSetObjectForKey { id object = [[NSObject alloc] init]; id key = @"foo"; ! [cache setObject:object forKey:key]; ! XCTAssertEqual(cache.currentSize, 1U); XCTAssertEqualObjects([cache objectForKey:key], object); }

Slide 90

Slide 90 text

✓ setObject:forKey:ͷ࣮ߦ࣌ʹsizeLimitΛ௒͑Δ৔߹͸ʁ ✓ setObject:forKey:ͷ࣮ߦޙʹsizeLimitΛখͨ͘͞͠৔߹͸ʁ ✓ removeAllObjectsͷ࣮ߦޙͷcurrentSize͸ʁ ͱ͍͏৚݅ΛσϞΞϓϦ্Ͱຖճσόοά͢Δ͸ඇৗʹͭΒ͍͕ɺ Ϣχοτςετ͸1౓ॻ͚͹܁Γฦ࣮͠ߦͰ͖Δɻ

Slide 91

Slide 91 text

ίʔυ͕յΕ͍ͯΔ͜ͱΛ͙͢ʹൃݟͰ͖Δ ௕ظʹΘͨͬͯෳ਺ਓ͕ϝϯςφϯε͢ΔϓϩάϥϜ͸յΕ΍͍͢ ςετ͸ϓϩάϥϜ͕ਖ਼͍͜͠ͱͷূ໌Ͱ͸ͳ͍

Slide 92

Slide 92 text

✓ setObject:forKey:ͷ࣮ߦ࣌ʹsizeLimitΛ௒͑Δ৔߹͸ʁ ✓ setObject:forKey:ͷ࣮ߦޙʹsizeLimitΛখͨ͘͞͠৔߹͸ʁ ✓ removeAllObjectsͷ࣮ߦޙͷcurrentSize͸ʁ ͲΕ͔1͚ͭͩյΕͨ͜ͱΛσϞΞϓϦ্Ͱ ݕ஌͢Δ͜ͱ͸೉͍͕͠ɺϢχοτςετͳΒ؆୯

Slide 93

Slide 93 text

ϥΠϒϥϦͷςετͷϝϦοτ͸ ίετʹݟ߹͏͜ͱ͕ଟ͍ ΞϓϦͱൺ΂ͯ࢓༷มߋ͕͘͢ͳ͍ͷͰɺ ςετίʔυ͕ΰϛʹͳΔ֬཰͕௿͍

Slide 94

Slide 94 text

ϥΠϒϥϦʹର͢ΔϢχοτςετΛॻ͘ཧ༝͸े෼

Slide 95

Slide 95 text

3.2.CIΛಋೖ͢Δ

Slide 96

Slide 96 text

͔ͤͬ͘ςετΛॻ͍ͨͷͰ࣮֬ʹ࣮ߦ͍ͨ͠ git pushͷલʹඞͣςετΛ࣮ߦͰ͖Δਓؒ͸গͳ͍

Slide 97

Slide 97 text

Git repository CI server Developer git push git hook Build report CI

Slide 98

Slide 98 text

git push͢Δͱ΋Εͳ͘Ϩϙʔτ͕΋Β͑Δ࢓૊Έ ✓ ϏϧυͰ͖Δ͔ʁ ✓ ςετ͸௨͔ͬͨʁ ✓ ίʔυΧόϨοδ͸ʁ

Slide 99

Slide 99 text

3.2.1.CIͷηοτΞοϓ

Slide 100

Slide 100 text

࠷୹ϧʔτ: λʔϛφϧ͔ΒϏϧυͰ͖ΔΑ͏ʹ

Slide 101

Slide 101 text

xcodebuild clean test \ -sdk iphonesimulator \ -workspace ISDiskCache.xcworkspace \ -scheme ISDiskCache \ -configuration Debug \ -destination "name=iPhone Retina (4-inch),OS=7.0" ཁ͢ΔʹΫϦʔϯͯ͠ςετͯ͠ͶͬͯίϚϯυ ͋ͱ͸͜ΕΛCIαʔόʔʹ఻͑Δ͚ͩͰOK

Slide 102

Slide 102 text

3.2.2.WebαʔϏε

Slide 103

Slide 103 text

CI αʔϏε

Slide 104

Slide 104 text

Git repository CI server Developer git push git hook Build report

Slide 105

Slide 105 text

GitHub Developer git push git hook Build report

Slide 106

Slide 106 text

✓ public repository͸ແྉ ✓ GitHub࿈ܞ ✓ status badge

Slide 107

Slide 107 text

֘౰ίϛοτͷϏϧυͷঢ়ଶ͕Θ͔Δ !!!

Slide 108

Slide 108 text

ίʔυΧόϨοδදࣔαʔϏε

Slide 109

Slide 109 text

֘౰ίϛοτͷίʔυΧόϨοδ͕Θ͔Δ

Slide 110

Slide 110 text

GitHub Developer git push git hook Build report Coverage report

Slide 111

Slide 111 text

✓ public repository͸ແྉ ✓ GitHub࿈ܞ ✓ status badge

Slide 112

Slide 112 text

྆ํηοτΞοϓ͢Δͱ͜Μͳײ͡

Slide 113

Slide 113 text

https://github.com/ishkawa/ISDiskCache/

Slide 114

Slide 114 text

3.3.Ϣχοτςετ·ͱΊ

Slide 115

Slide 115 text

✓ ςετͷಋೖͰ։ൃ͕଎͘ͳΔՕॴ΋͋Δ ✓ յΕͨՕॴΛൃݟ͠΍͘͢ͳΔ ✓ ϥΠϒϥϦͷςετ͸ΞϓϦͷςετΑΓߴCP ✓ CIͰৗʹςετ͞Εͨঢ়ଶΛอͭ͜ͱ͕Ͱ͖Δ

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

·ͱΊ

Slide 118

Slide 118 text

1.ಋೖઌͷΞϓϦͱͷিಥʹؾΛ͚ͭΔ 2.ଞਓʹΘ͔Γ΍͍͢ΠϯλʔϑΣʔεʹ͢Δ 3.඼࣭͕མͪʹ͍͘࢓૊ΈΛಋೖ͢Δ ϥΠϒϥϦΛެ։͢Δͱ͖͸….