Revision [367]
This is an old revision of NotificationCenter made by JohnMcIntosh on 2009-09-09 12:08:54.
- (void)applicationWillTerminate:(UIApplication *)application { [[NSNotificationCenter defaultCenter] postNotificationName: @"ApplicationWillTerminate" object: self]; }
The NSNotificationCenter logic will send ApplicationWillTerminate to any interested parties. Then in Smalltalk we do:
etupApplicationWillTerminateHandler | defaultCenter selectorString nameString | selectorString := 'applicationWillTerminate:'. nameString := 'ApplicationWillTerminate' asNSStringUTF8. self squeakProxy addSigViaString: selectorString aSignature: 'v@:@'. ObjectiveCBridge performSelectorOnMainThread: [defaultCenter := (ObjectiveCBridge classObjectForName: #NSNotificationCenter) defaultCenter. defaultCenter addObserver: squeakProxy squeakProxy selector: (ObjectiveCBridge findSelectorCalled: selectorString) name: nameString object: 0]. nameString release.
Then on the Proxy we handle the notifiication, in this case since we aren't doing UIKit work we can do the task directly
applicationWillTerminate: aNotification self ui applicationWillTerminate: aNotification applicationWillTerminate: aNotification ObjectiveCBridge wrapWithAutoReleasePool: [self saveWebViewURL]. saveWebViewURL | defaults key possibleRequest url host | defaults := (ObjectiveCBridge classObjectForName: #NSUserDefaults) standardUserDefaults. key := 'WikiServerLastURLUsed' asNSStringUTF8. possibleRequest := self webView request. possibleRequest isNil ifTrue: [^self]. defaults setObject: possibleRequest URL path forKey: key. defaults synchronize. key release.