UILocalNotification - mutable copying
-
04-06-2021 - |
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 methodcopy
Question
- Am I doing the correct thing or should I be using a different method to create a mutable copy. (
mutableCopy
is not implemented forUILocalNotification
- Does copy actually do a mutable copy ?
- Is it necessary to create a copy at all, will
scheduleLocalNotification:
create a new copy anyway ?
Solução
- Yes,
copy
's fine. mutableCopy
generally applies to types which distinguish immutable and mutable flavors. since the type does not make that distinction,copy
is 'mutable'.- 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