/
BWToolbarItem.m
62 lines (50 loc) · 1.25 KB
/
BWToolbarItem.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
//
// BWToolbarItem.m
// BWToolkit
//
// Created by Brandon Walkin (www.brandonwalkin.com)
// All code is provided under the New BSD license.
//
#import "BWToolbarItem.h"
#import "NSString+BWAdditions.h"
@interface BWToolbarItem ()
@property (copy) NSString *identifierString;
@end
@interface NSToolbarItem (BWTIPrivate)
- (void)_setItemIdentifier:(id)fp8;
- (id)initWithCoder:(NSCoder *)coder;
- (void)encodeWithCoder:(NSCoder*)coder;
@end
@implementation BWToolbarItem
@synthesize identifierString;
- (id)initWithCoder:(NSCoder *)coder
{
if ((self = [super initWithCoder:coder]) != nil)
{
[self setIdentifierString:[coder decodeObjectForKey:@"BWTIIdentifierString"]];
}
return self;
}
- (void)encodeWithCoder:(NSCoder*)coder
{
[super encodeWithCoder:coder];
[coder encodeObject:[self identifierString] forKey:@"BWTIIdentifierString"];
}
- (void)setIdentifierString:(NSString *)aString
{
if (identifierString != aString)
{
[identifierString release];
identifierString = [aString copy];
}
if (identifierString == nil || [identifierString isEqualToString:@""])
[self _setItemIdentifier:[[NSString randomUUID] retain]];
else
[self _setItemIdentifier:identifierString];
}
- (void)dealloc
{
[identifierString release];
[super dealloc];
}
@end