Erik Scrafford's workaround for http://code.google.com/p/route-me/issues/detail?id=137
Showing
4 changed files
with
95 additions
and
2 deletions
MapView/Map/RMCountedSet.h
0 → 100644
1 | +// | ||
2 | +// RMCountedSet.h | ||
3 | +// | ||
4 | +// Copyright (c) 2010, Route-Me Contributors | ||
5 | +// All rights reserved. | ||
6 | +// | ||
7 | +// Redistribution and use in source and binary forms, with or without | ||
8 | +// modification, are permitted provided that the following conditions are met: | ||
9 | +// | ||
10 | +// * Redistributions of source code must retain the above copyright notice, this | ||
11 | +// list of conditions and the following disclaimer. | ||
12 | +// * Redistributions in binary form must reproduce the above copyright notice, | ||
13 | +// this list of conditions and the following disclaimer in the documentation | ||
14 | +// and/or other materials provided with the distribution. | ||
15 | +// | ||
16 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
17 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
18 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
19 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
20 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
21 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
22 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
23 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
24 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
25 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
26 | +// POSSIBILITY OF SUCH DAMAGE. | ||
27 | + | ||
28 | +#import <Foundation/Foundation.h> | ||
29 | + | ||
30 | + | ||
31 | +@interface RMCountedSet : NSCountedSet { | ||
32 | + | ||
33 | +} | ||
34 | + | ||
35 | +@end |
MapView/Map/RMCountedSet.m
0 → 100644
1 | +// | ||
2 | +// RMCountedSet.m | ||
3 | +// | ||
4 | +// Copyright (c) 2010, Route-Me Contributors | ||
5 | +// All rights reserved. | ||
6 | +// | ||
7 | +// Redistribution and use in source and binary forms, with or without | ||
8 | +// modification, are permitted provided that the following conditions are met: | ||
9 | +// | ||
10 | +// * Redistributions of source code must retain the above copyright notice, this | ||
11 | +// list of conditions and the following disclaimer. | ||
12 | +// * Redistributions in binary form must reproduce the above copyright notice, | ||
13 | +// this list of conditions and the following disclaimer in the documentation | ||
14 | +// and/or other materials provided with the distribution. | ||
15 | +// | ||
16 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
17 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
18 | +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
19 | +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
20 | +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
21 | +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
22 | +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
23 | +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
24 | +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
25 | +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
26 | +// POSSIBILITY OF SUCH DAMAGE. | ||
27 | + | ||
28 | +#import "RMCountedSet.h" | ||
29 | + | ||
30 | +// Workaround for changed behavior of NSCountedSet in os4.0 beta1&2 | ||
31 | +// it used to always retain the first object added | ||
32 | +// new behavior is to replace that object with the one passed into | ||
33 | +// addObject: and removeObject: | ||
34 | +// this is a problem for us because of the dummy tiles being added/removed | ||
35 | +// that don't actually contain the same data as the real tile objects | ||
36 | +// even though isEqual: will return true. | ||
37 | + | ||
38 | +@implementation RMCountedSet | ||
39 | + | ||
40 | +-(void)addObject:(id)object | ||
41 | +{ | ||
42 | + id objectToAdd = [self member:object]; | ||
43 | + if ( ! objectToAdd ) | ||
44 | + objectToAdd = object; | ||
45 | + [super addObject:objectToAdd]; | ||
46 | +} | ||
47 | + | ||
48 | +-(void)removeObject:(id)object | ||
49 | +{ | ||
50 | + id objectToRemove = [self member:object]; | ||
51 | + if ( ! objectToRemove ) | ||
52 | + return; | ||
53 | + [super removeObject:objectToRemove]; | ||
54 | +} | ||
55 | + | ||
56 | + | ||
57 | +@end |
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | # import <Cocoa/Cocoa.h> | 32 | # import <Cocoa/Cocoa.h> |
33 | #endif | 33 | #endif |
34 | #import "RMTile.h" | 34 | #import "RMTile.h" |
35 | +#import "RMCountedSet.h" | ||
35 | 36 | ||
36 | @class RMTileImage; | 37 | @class RMTileImage; |
37 | @protocol RMTileSource; | 38 | @protocol RMTileSource; |
@@ -49,7 +50,7 @@ | @@ -49,7 +50,7 @@ | ||
49 | IBOutlet id delegate; | 50 | IBOutlet id delegate; |
50 | id<RMTileSource> tileSource; | 51 | id<RMTileSource> tileSource; |
51 | 52 | ||
52 | - NSCountedSet *images; | 53 | + RMCountedSet *images; |
53 | } | 54 | } |
54 | 55 | ||
55 | -(id) initWithDelegate: (id) _delegate; | 56 | -(id) initWithDelegate: (id) _delegate; |
-
Please register or login to post a comment