• 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: constants? strings? what do i wrong?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: constants? strings? what do i wrong?


  • Subject: Re: constants? strings? what do i wrong?
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 2 Feb 2004 18:01:48 -0600

On Feb 2, 2004, at 1:54 PM, Steffi Krause wrote:
@interface MyClass: NSObject
{
#define ASTRING @"Stringcontent"
}

It looks like you expect ASTRING to be somehow "within" MyClass. It isn't. This is just like plain old C; preprocessor definitions have exactly the same scope they do there.

Also, I'd write

extern NSString * const MyString;

in the header file -- not as part of a class declaration -- and then in the implementation file, I'd write

NSString * const MyString = @"MyString";

to mimic the style of the Foundation headers. This lets the compiler catch typos.

NSLog (ASTRING);

and i get an error like this: MyApp has exited due to signal 10 (SIGBUS).

what is wrong here? i'm stuck!

NSLog works like printf, it expects a format string. So if you have % characters in ASTRING, NSLog could be expecting extra arguments that aren't present on the stack.

-- Chris

--
Chris Hanson <email@hidden>
bDistributed.com, Inc.
Outsourcing Vendor Evaluation
Custom Mac OS X Development
Cocoa Developer Training
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >constants? strings? what do i wrong? (From: "Steffi Krause" <email@hidden>)

  • Prev by Date: Re: Cocoa/Windows parallel dvlpmt
  • Next by Date: Re: Updating text fields in Cocoa.
  • Previous by thread: Re: constants? strings? what do i wrong?
  • Next by thread: Re: constants? strings? what do i wrong?
  • Index(es):
    • Date
    • Thread