Re: (no subject)
Re: (no subject)
- Subject: Re: (no subject)
- From: Douglas Norton <email@hidden>
- Date: Mon, 21 Feb 2005 11:53:00 +0000
<x-tad-smaller>Stefan,
If I make the array const, then this compiles fine when I place it in one of my .mm files, (YMMV)
const</x-tad-smaller><x-tad-smaller> NSString* TNKCoreTaskDidLaunchNotification = </x-tad-smaller><x-tad-smaller>@"coreTaskDidLaunch:"</x-tad-smaller><x-tad-smaller>;
</x-tad-smaller><x-tad-smaller>const</x-tad-smaller><x-tad-smaller> NSString* TNKCoreTaskDidWriteToStdOutNotification = </x-tad-smaller><x-tad-smaller>@"coreTaskDidWriteToStdOut:"</x-tad-smaller><x-tad-smaller>;
</x-tad-smaller><x-tad-smaller>const</x-tad-smaller><x-tad-smaller> NSString* TNKCoreTaskDidTerminateNotification = </x-tad-smaller><x-tad-smaller>@"coreTaskDidTerminate:"</x-tad-smaller><x-tad-smaller>;
</x-tad-smaller><x-tad-smaller>const</x-tad-smaller><x-tad-smaller> NSString* delegationNotifications[] = {
TNKCoreTaskDidLaunchNotification,
TNKCoreTaskDidWriteToStdOutNotification,
TNKCoreTaskDidTerminateNotification,
</x-tad-smaller><x-tad-smaller>nil</x-tad-smaller><x-tad-smaller>
};
</x-tad-smaller>
Douglas
On 21 Feb 2005, at 11:33, Stefan Fisk wrote:
I'm sorry, but i get the same error even when i leave the consts out completely.
It clearly seems to be something you're just not allowed to do, but i can't make out why, it just looks like an array of pointers to me..
2005-02-21 kl. 12.04 skrev Darkshadow:
On Feb 21, 2005, at 4:36 AM, Stefan Fisk wrote:
Hi!
I'm trying to simplify my -setDelegate: a bit, and therefore want to put all my notifications in a c-style array.
But, could anyone explain why the code snippet below gives me the following error:
<x-tad-smaller>
TNKCoreTask.m:18: error: (near initialization for `delegationNotifications[0]')
TNKCoreTask.m:18: error: initializer element is not constant
TNKCoreTask.m:19: error: (near initialization for `delegationNotifications[1]')
TNKCoreTask.m:19: error: initializer element is not constant
TNKCoreTask.m:21: error: (near initialization for `delegationNotifications[2]')
TNKCoreTask.m:21: error: initializer element is not constant
</x-tad-smaller>
I've tried googling for a couple of hours, but i found nothing that felt relevant.
My reason for doing it this way is that i want to standardize my -setDelegate: methods as far as possible, so that there's only place in the code to edit when adding notifications.
CODE:
NSString * const TNKCoreTaskDidLaunchNotification = @"coreTaskDidLaunch:";
NSString * const TNKCoreTaskDidWriteToStdOutNotification = @"coreTaskDidWriteToStdOut:";
NSString * const TNKCoreTaskDidTerminateNotification = @"coreTaskDidTerminate:";
Try const NSString *
NSString *delegationNotifications[] = {
TNKCoreTaskDidLaunchNotification,
TNKCoreTaskDidWriteToStdOutNotification,
TNKCoreTaskDidTerminateNotification,
nil
};
Thanks on forehand
Stefan Fisk _______________________________________________
--
Douglas J. Norton
________________________________________________________________
email@hidden <http://www.2point5fish.com>
________________________________________________________________
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden