which to use id or instancetype

use instancetype

  • readable
  • (type safe)

ex. generally in ‘init’ …

‘init’ returns 'the instance’

so it’s clear if it’s written ‘instancetype is returned’

(id) init; // what type will be returned?
(instancetype) init; // ah ... instance will be returned

official

(continue to survey…, instancetype will make type safe)

developer.apple.com

unofficial

Why you should use instancetype instead of id | tewha.net

takebayashi.asia

qiita.com