Index: README.md ================================================================== --- README.md +++ README.md @@ -321,11 +321,11 @@ To create your first, empty application, you can use `objfw-new`: $ objfw-new --app MyFirstApp - This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching]` + This creates a file `MyFirstApp.m`. The `-[applicationDidFinishLaunching:]` method is called as soon as ObjFW finished all initialization. Use this as the entry point to your own code. For example, you could add the following line there to create a "Hello World": [OFStdOut writeLine: @"Hello World!"]; Index: generators/library/LibraryGenerator.m ================================================================== --- generators/library/LibraryGenerator.m +++ generators/library/LibraryGenerator.m @@ -29,11 +29,11 @@ @end OF_APPLICATION_DELEGATE(LibraryGenerator) @implementation LibraryGenerator -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFURI *sourcesURI = [[OFFileManager defaultManager].currentDirectoryURI URIByAppendingPathComponent: @"../../src"]; OFURI *runtimeLibraryURI = [sourcesURI URIByAppendingPathComponent: @"runtime/amiga-library.xml"]; Index: generators/unicode/TableGenerator.m ================================================================== --- generators/unicode/TableGenerator.m +++ generators/unicode/TableGenerator.m @@ -60,11 +60,11 @@ } return self; } -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFHTTPRequest *request; [OFStdOut writeString: @"Downloading UnicodeData.txt…"]; _state = stateUnicodeData; Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -27,10 +27,16 @@ @class OFMutableArray OF_GENERIC(ObjectType); @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType); @class OFSandbox; @class OFString; +/** + * @brief A notification that will be sent when the application did finish + * launching. + */ +extern const OFNotificationName OFApplicationDidFinishLaunchingNotification; + /** * @brief A notification that will be sent when the application will terminate. */ extern const OFNotificationName OFApplicationWillTerminateNotification; @@ -49,11 +55,11 @@ * * // In MyAppDelegate.m: * OF_APPLICATION_DELEGATE(MyAppDelegate) * * @implementation MyAppDelegate - * - (void)applicationDidFinishLaunching + * - (void)applicationDidFinishLaunching: (OFNotification *)notification * { * [OFApplication terminate]; * } * @end * @endcode @@ -79,18 +85,24 @@ */ @protocol OFApplicationDelegate /** * @brief A method which is called when the application was initialized and is * running now. + * + * @param notification A notification with name + * OFApplicationDidFinishLaunchingNotification */ -- (void)applicationDidFinishLaunching; +- (void)applicationDidFinishLaunching: (OFNotification *)notification; @optional /** * @brief A method which is called when the application will terminate. + * + * @param notification A notification with name + * OFApplicationWillTerminateNotification */ -- (void)applicationWillTerminate; +- (void)applicationWillTerminate: (OFNotification *)notification; /** * @brief A method which is called when the application received a SIGINT. * * @warning You are not allowed to send any messages inside this method, as Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -83,27 +83,30 @@ andWideArgumentValues: (wchar_t *[])wargv; #endif - (void)of_run; @end +const OFNotificationName OFApplicationDidFinishLaunchingNotification = + @"OFApplicationDidFinishLaunchingNotification"; const OFNotificationName OFApplicationWillTerminateNotification = @"OFApplicationWillTerminateNotification"; static OFApplication *app = nil; static void atexitHandler(void) { id delegate = app.delegate; - - [[OFNotificationCenter defaultCenter] - postNotificationName: OFApplicationWillTerminateNotification + OFNotification *notification = [OFNotification + notificationWithName: OFApplicationWillTerminateNotification object: app]; - if ([delegate respondsToSelector: @selector(applicationWillTerminate)]) - [delegate applicationWillTerminate]; + if ([delegate respondsToSelector: @selector(applicationWillTerminate:)]) + [delegate applicationWillTerminate: notification]; [delegate release]; + + [[OFNotificationCenter defaultCenter] postNotification: notification]; #if defined(OF_HAVE_THREADS) && defined(OF_HAVE_SOCKETS) && \ defined(OF_AMIGAOS) && !defined(OF_MORPHOS) OFSocketDeinit(); #endif @@ -577,10 +580,11 @@ - (void)of_run { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop; + OFNotification *notification; #ifdef OF_HAVE_THREADS [OFThread of_createMainThread]; runLoop = [OFRunLoop currentRunLoop]; #else @@ -596,11 +600,19 @@ * of_setMainRunLoop: retained it. However, we only have a weak * reference to it now, whereas we had a strong reference before. */ pool = objc_autoreleasePoolPush(); - [_delegate applicationDidFinishLaunching]; + + notification = [OFNotification + notificationWithName: OFApplicationDidFinishLaunchingNotification + object: app]; + + [[OFNotificationCenter defaultCenter] postNotification: notification]; + + [_delegate applicationDidFinishLaunching: notification]; + objc_autoreleasePoolPop(pool); [runLoop run]; } Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -347,11 +347,11 @@ [OFStdOut reset]; [OFStdOut eraseLine]; } } -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { #if defined(OF_IOS) && defined(OF_HAVE_FILES) CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); UInt8 resourcesPath[PATH_MAX]; Index: tests/terminal/TerminalTests.m ================================================================== --- tests/terminal/TerminalTests.m +++ tests/terminal/TerminalTests.m @@ -25,11 +25,11 @@ @end OF_APPLICATION_DELEGATE(TerminalTests) @implementation TerminalTests -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFArray *colors = [OFArray arrayWithObjects: [OFColor black], [OFColor silver], [OFColor grey], [OFColor white], [OFColor maroon], [OFColor red], [OFColor purple], [OFColor fuchsia], [OFColor green], [OFColor lime], [OFColor olive], Index: utils/objfw-new/NewApp.m ================================================================== --- utils/objfw-new/NewApp.m +++ utils/objfw-new/NewApp.m @@ -46,11 +46,12 @@ @"@end\n" @"\n" @"OF_APPLICATION_DELEGATE(%@)\n" @"\n" @"@implementation %@\n" - @"- (void)applicationDidFinishLaunching\n" + @"- (void)applicationDidFinishLaunching: " + @"(OFNotification *)notification\n" @"{\n" @" [OFApplication terminate];\n" @"}\n" @"@end\n", name, name, name]; Index: utils/objfw-new/ObjFWNew.m ================================================================== --- utils/objfw-new/ObjFWNew.m +++ utils/objfw-new/ObjFWNew.m @@ -38,11 +38,11 @@ [OFApplication terminateWithStatus: 1]; } @implementation ObjFWNew -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { bool app, class; OFString *superclass = nil, *name; OFMutableArray OF_GENERIC(OFString *) *properties = nil; const OFOptionsParserOption options[] = { Index: utils/ofarc/OFArc.m ================================================================== --- utils/ofarc/OFArc.m +++ utils/ofarc/OFArc.m @@ -165,11 +165,11 @@ [archive addFiles: expandedFiles]; } @implementation OFArc -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *outputDir, *encodingString, *type; const OFOptionsParserOption options[] = { { 'a', @"append", 0, NULL, NULL }, { 'c', @"create", 0, NULL, NULL }, Index: utils/ofdns/OFDNS.m ================================================================== --- utils/ofdns/OFDNS.m +++ utils/ofdns/OFDNS.m @@ -78,11 +78,11 @@ if (_inFlight == 0) [OFApplication terminateWithStatus: _errors]; } -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *DNSClassString, *server; const OFOptionsParserOption options[] = { { 'c', @"class", 1, NULL, &DNSClassString }, { 'h', @"help", 0, NULL, NULL }, Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -66,11 +66,11 @@ [OFStdOut writeFormat: @" %@\n", path]; } @implementation OFHash -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { int exitStatus = 0; bool calculateMD5, calculateRIPEMD160, calculateSHA1, calculateSHA224; bool calculateSHA256, calculateSHA384, calculateSHA512; const OFOptionsParserOption options[] = { Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -410,11 +410,11 @@ @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } } -- (void)applicationDidFinishLaunching +- (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *outputPath; const OFOptionsParserOption options[] = { { 'b', @"body", 1, NULL, NULL }, { 'c', @"continue", 0, &_continue, NULL },