Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SwiftFriendlyObjective-C/try! Swift Tokyo 2017 ...

SwiftFriendlyObjective-C/try! Swift Tokyo 2017 RejectCon

Noritaka Kamiya

February 28, 2017
Tweet

More Decks by Noritaka Kamiya

Other Decks in Programming

Transcript

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

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

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

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

    open var text: String open var images: [Any] } Nullability
  5. 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
  6. 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
  7. open class Memo : NSObject { open var createdAt: Date

    open var text: String open var images: [Any] } Nullability
  8. 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
  9. LightWeight Generics open class Memo : NSObject { open var

    createdAt: Date open var text: String open var images: [UIImage] }
  10. memo.save { _ in } TrailingClosure typedef void (^SomeCompletionHandler)(NSString *);

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

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

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