An object that has made itself the delegate of a standard Cocoa object is probably interested in receiving notifications from that object as well. For example,if you have implemented a delegate to handle the windowshouldClose: delegate method for a window,that same object is likely to be interested in the NSWindowDIDResiZenotification from that same window.
If a standard Cocoa object has a delegate and posts notifications,it is automatically registered as an observer for the methods the object implements. If you are implementing such a delegate,how would you kNow what to call the method?
The naming convention is simple: Start with the name of the notification. Remove NS from the beginning,and make the first letter lowercase. Remove Notification from the end. Add a colon. For example,to be notifIEd that the window has posted anNSWindowDIDResiZenotification,the delegate would implement the following method:
- (voID)windowDIDResize:(NSNotification *)aNotification
This method will be called automatically after the window resizes. You can also find this method Listed in the documentation and header files for the class NSWindow.
总结以上是内存溢出为你收集整理的Delegates and Notifications全部内容,希望文章能够帮你解决Delegates and Notifications所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)