Pergunta

Overview:

  • I am copying an instance of UILocalNotification and making changes to it to the newly created instance
  • Then I schedule the newly created instance of UILocalNotification

How I am copying

  • I am copying the instance of UILocalNotification by invoking the method copy

Question

  1. Am I doing the correct thing or should I be using a different method to create a mutable copy. (mutableCopy is not implemented for UILocalNotification
  2. Does copy actually do a mutable copy ?
  3. Is it necessary to create a copy at all, will scheduleLocalNotification: create a new copy anyway ?
Foi útil?

Solução

  1. Yes, copy's fine.
  2. mutableCopy generally applies to types which distinguish immutable and mutable flavors. since the type does not make that distinction, copy is 'mutable'.
  3. typically, you would assume that you should need to copy the argument. in this case, the docs specify that scheduleLocalNotification: creates a copy of the parameter. explicitly copying is not strictly necessary.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top