• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


  • Subject: Re: (no subject)
  • From: Stefan Fisk <email@hidden>
  • Date: Mon, 21 Feb 2005 13:03:02 +0100

That's an Objective-C++ file though, so it's probably not really legal to do in pure Objective-C++, should do as a work-around for now though, thanks.
but still, the problem eludes me.

2005-02-21 kl. 12.53 skrev Douglas Norton:

<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

References: 
 >(no subject) (From: Stefan Fisk <email@hidden>)
 >Re: (no subject) (From: Darkshadow <email@hidden>)
 >Re: (no subject) (From: Stefan Fisk <email@hidden>)
 >Re: (no subject) (From: Douglas Norton <email@hidden>)

  • Prev by Date: Re: convert int to NSString (Newbie)
  • Next by Date: Re: Lining up NSViews in NSScrollView
  • Previous by thread: Re: (no subject)
  • Next by thread: spawing a server...
  • Index(es):
    • Date
    • Thread