SwiftFriendlyObjective-C/try! Swift Tokyo 2017 RejectCon

SwiftFriendlyObjective-C/try! Swift Tokyo 2017 RejectCon

8e2e0edcf1ffc34e5fbc9ccf7c9a1328?s=128

Noritaka Kamiya

February 28, 2017
Tweet

Transcript

  1. SwiftϑϨϯυϦʔObjective-C @nolili Noritaka Kamiya

  2. None
  3. None
  4. None
  5. None
  6. Swift❤ Objective-C❤

  7. try! Swift SwiftϑϨϯυϦʔObjective-C

  8. try! Swift EXC_BAD_INSTRUCTION

  9. try! Swift EXC_BAD_INSTRUCTION Rejected

  10. Swift❤ Objective-C❤

  11. جຊ

  12. Nullability

  13. @interface Memo : NSObject @property (nonatomic) NSDate *createdAt; @property (nonatomic)

    NSString *text; @property (nonatomic) NSArray *images; @end Nullability
  14. Nullability open class Memo : NSObject { open var createdAt:

    Date! open var text: String! open var images: [Any]! }
  15. @interface Memo : NSObject @property (nonatomic, nonnull) NSDate *createdAt; @property

    (nonatomic, nonnull) NSString *text; @property (nonatomic, nonnull) NSArray *images; @end Nullability
  16. open class Memo : NSObject { open var createdAt: Date

    open var text: String open var images: [Any] } Nullability
  17. NS_ASSUME_NONNULL_BEGIN @interface Memo : NSObject @property (nonatomic) NSDate *createdAt; @property

    (nonatomic) NSString *text; @property (nonatomic) NSArray *images; @end NS_ASSUME_NONNULL_END Nullability
  18. LightWeight Generics

  19. LightWeight Generics NS_ASSUME_NONNULL_BEGIN @interface Memo : NSObject @property (nonatomic) NSDate

    *createdAt; @property (nonatomic) NSString *text; @property (nonatomic) NSArray *images; @end NS_ASSUME_NONNULL_END
  20. open class Memo : NSObject { open var createdAt: Date

    open var text: String open var images: [Any] } Nullability
  21. LightWeight Generics NS_ASSUME_NONNULL_BEGIN @interface Memo : NSObject @property (nonatomic) NSDate

    *createdAt; @property (nonatomic) NSString *text; @property (nonatomic) NSArray<UIImage *> *images; @end NS_ASSUME_NONNULL_END
  22. LightWeight Generics open class Memo : NSObject { open var

    createdAt: Date open var text: String open var images: [UIImage] }
  23. ΞϊςʔγϣϯͰSwiftଆ΁ؾ࣋ͪΛද໌͢Δ

  24. Blocks / Closure

  25. memo.save { _ in } TrailingClosure typedef void (^SomeCompletionHandler)(NSString *);

    @interface Memo : NSObject - (void)save:(SomeCompletionHandler)handler; @end
  26. Closure typedef void (^SomeCompletionHandler)(NSString *); @interface Memo : NSObject -

    (void)save:(nullable SomeCompletionHandler)handler; @end memo.save()
  27. noescape typedef void (^SomeCompletionHandler)(NSString *); @interface Notes : NSObject +

    (void)save:(__attribute__((noescape)) SomeCompletionHandler)handler; @end memo.save { _ in someSelfMethod() // self. ෆཁ }
  28. Error/Exception

  29. Error + (BOOL)send:(NSError **)error; open class func send() throws

  30. @throw @try @catch @finally

  31. @throw @try @catch @finally X

  32. w $PEJOH(VJEFMJOFTGPS$PDPBʹԊͬͯॻ͘ w (FOFSBUFE*OUFSGBDFΛΈΔ w 4UBUJD"OBMZ[FSΛ׆༻͢Δ w 4XJGU͔ΒJNQPSUͯ͠ΈΔ w ͔͍͍ͬ͜0CKFDUJWF$͸4XJGU͔ΒΈͯ΋͔͍͍ͬ͜

    ৺͕͚͍ͯΔ͜ͱ
  33. None
  34. None
  35. None
  36. None
  37. w $PDPBίʔσΟϯάΨΠυϥΠϯʹԊͬͯॻ͘ w (FOFSBUFE*OUFSGBDFΛΈΔ w 4UBUJD"OBMZ[FSΛ׆༻͢Δ w 4XJGU͔ΒJNQPSUͯ͠ΈΔ w ͔͍͍ͬ͜0CKFDUJWF$͸4XJGU͔ΒΈͯ΋͔͍͍ͬ͜

    ৺͕͚͍ͯΔ͜ͱ
  38. SwiftϑϨϯυϦʔObjective-C @nolili Noritaka Kamiya