• 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
Newbie question: setting a NSNumber
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie question: setting a NSNumber


  • Subject: Newbie question: setting a NSNumber
  • From: David Sinclair <email@hidden>
  • Date: Tue, 21 May 2002 13:12:26 -0700

Hi. I hate to ask such a simple question, but I'm having trouble with it, and can't find the answer anywhere. I'm trying to set a NSNumber. But using much the same code that works for NSStrings and NSCalendarDate crashes (signal 10 or 11) with NSNumber. What's wrong?

NSNumber *dub = [NSNumber numberWithDouble:123.4];

[demo setBlah:dub];

where setBlah is:

- (void) setBlah:(NSNumber *)value
{
[blah autorelease];
blah = [value copy];
}

or

- (void)setBlah:(NSNumber *)value
{
[value retain];
[blah release];
blah = value;
}

(Any comments of which is best -- or another variation? I've seen several different forms in various places.)

This seems so trivial an operation... but it isn't working. It crashes when the autorelease pool is released in the main loop, which suggests the retain etc stuff is wrong, but it looks okay to me.

--

David Sinclair - email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Newbie question: setting a NSNumber
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Checkbox as title for NSBox
  • Next by Date: Re: Newbie question: setting a NSNumber
  • Previous by thread: Test Call for an Alarm Clock
  • Next by thread: Re: Newbie question: setting a NSNumber
  • Index(es):
    • Date
    • Thread