forked from JanX2/CoolOutliner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCONode.m
64 lines (53 loc) · 1.3 KB
/
CONode.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
57
58
59
60
61
62
63
64
//
// CONode.m
// CoolOutliner
//
// Created by Jan on 10.07.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "CONode.h"
@implementation CONode
@synthesize description;
@synthesize expandState;
- (id)init
{
if (self = [super init])
{
title = [[NSString alloc] initWithString:@"Untitled"];
description = [[NSString alloc] initWithString:@"- No description -"];
text = [[NSTextStorage alloc] init];
}
return self;
}
- (void)dealloc
{
[description release];
[text release];
[super dealloc];
}
/*
Note that setText: can accept an NSTextStorage, an NSAttributedString, an
NSMutableAttributedString, or a simple NSString – any will work. (This is a nifty tip I picked up from
an article over at www.projectomega.org.)
*/
- (void)setText:(id)newText
{
if ([newText isKindOfClass:[NSAttributedString class]])
[text replaceCharactersInRange:NSMakeRange(0,[text length])
withAttributedString:newText];
else
[text replaceCharactersInRange:NSMakeRange(0,[text length]) withString:newText];
}
- (NSTextStorage *)text
{
return text;
}
- (NSArray *)mutableKeys
{
return [[super mutableKeys] arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:
@"description",
@"text",
@"expandState",
nil]];
}
@end