<div dir="ltr">Howdy.<div><br></div><div>I've been building (on Linux) the latest off of master for Swift and the accompanying swift-corelibs-foundation. I can see where the great renaming is in full swing and have been updating my code accordingly.</div><div><br></div><div>One area where I'm a bit confused is with the new API for NotificationCenter and Notification.</div><div><br></div><div>In the past bare strings were acceptable for <font face="monospace, monospace">postNotificationName</font> and <font face="monospace, monospace">addObserverForName</font>. Yet now constructing a <font face="monospace, monospace">Notification</font> and <font face="monospace, monospace">Notification.Name</font> seem to be a bit unwieldy. Example:</div><div><br></div><div><div><font face="monospace, monospace">let ConnectedNotification = Notification(name:Notification.Name(rawValue:"ConnectedNotification"))</font></div></div><div><br></div><div><div>That seems to be quite convoluted and I'm not sure why there isn't a convenience init that allows for</div><div><br></div><div><div><font face="monospace, monospace">let ConnectedNotification = Notification(name:"ConnectedNotification")</font></div></div><div><br></div><div>Then, the APIs for post and observe seem to be mismatched:</div><div><br></div><div><font face="monospace, monospace">NotificationCenter.defaultCenter().postNotification(ConnectedNotification)</font></div><div><br></div><div>vs. </div><div><br></div><div><font face="monospace, monospace">NotificationCenter.defaultCenter().addObserverForName(ConnectedNotification.name)</font></div><div><br></div><div>I would think an <font face="monospace, monospace">addObserverForNotification</font> would be more appropriate here.</div><div><br></div><div>Finally, combining topics a bit, but they are related:</div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">let ConnectedNotification = Notification(name:Notification.Name(rawValue:"ConnectedNotification"))</font></div><div><font face="monospace, monospace">let DisconnectedNotification = Notification(name:Notification.Name(rawValue:"DisconnectedNotification"))</font></div></div><div><br></div><div>These notifications are for the same API, so I'm assuming I'm "doing this wrong" and that the more Swifty way would be too put these in a struct or enum, so I'm curious as to what folks recommend.</div><div><br></div><div>Thanks!</div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Joseph Bell<br><div><a href="http://dev.iachieved.it/iachievedit/" target="_blank">http://dev.iachieved.it/iachievedit/</a></div><div>@iachievedit</div></div></div></div></div>
</div></div>