Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-[NSNotificationCenter postNotificationName:object:] Can I pass nil for object?

Can I pass nil for the object argument of -[NSNotificationCenter postNotificationName:object:] since the observers don't care who the sender is, or is it better practice to pass self for the object argument even though the observers aren't checking who sent the notification?

like image 395
ma11hew28 Avatar asked Oct 10 '22 17:10

ma11hew28


1 Answers

Passing nil won't harm anything. It's just nice to be able to know what sent the notification, even if current observers don't need to know and don't check it.

like image 164
BoltClock Avatar answered Oct 14 '22 03:10

BoltClock