forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
FSNamedNumber.m
56 lines (42 loc) · 939 Bytes
/
FSNamedNumber.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* NamedNumber.h Copyright (c) 1998-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "FSNamedNumber.h"
@implementation FSNamedNumber
+ namedNumberWithDouble:(double)val name:(NSString *)theName
{
return [[[self alloc] initWithDouble:val name:theName] autorelease];
}
- (void) dealloc
{
[name release];
[super dealloc];
}
- (NSString *)description
{
if (name) return name;
else return [super description];
}
- (double) doubleValue
{
return value;
}
- initWithDouble:(double)val name:(NSString *)theName //designated initializer
{
if ((self = [super init]))
{
value = val;
name = [theName retain];
return self;
}
return nil;
}
///////////////// NSValue Class cluster primitives methods are implemented here
- (void)getValue:(void *)buffer
{
*(double *)buffer = value;
}
- (const char *)objCType
{
return @encode(typeof(value));
}
@end