Newbie question: setting a NSNumber
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.