Authored by Hal Mueller

Added deprecation log warnings. Registered RMMapContents for UIApplicationDidRec…

…eiveMemoryWarningNotification and cascaded didReceiveMemoryWarning calls to its components.
@@ -107,6 +107,7 @@ @@ -107,6 +107,7 @@
107 { 107 {
108 LogMethod(); 108 LogMethod();
109 [cache didReceiveMemoryWarning]; 109 [cache didReceiveMemoryWarning];
  110 + [tileSource didReceiveMemoryWarning];
110 } 111 }
111 112
112 -(NSString*) uniqueTilecacheKey 113 -(NSString*) uniqueTilecacheKey
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 #import <Foundation/Foundation.h> 28 #import <Foundation/Foundation.h>
29 #import "RMTileImage.h" 29 #import "RMTileImage.h"
30 30
31 -/// a tile image loaded from a local file 31 +/// RMTileImage subclass: a tile image loaded from a local file.
32 @interface RMFileTileImage : RMTileImage { 32 @interface RMFileTileImage : RMTileImage {
33 33
34 } 34 }
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 34
35 /*! \struct RMLatLongBounds 35 /*! \struct RMLatLongBounds
36 36
37 - \brief Specifies a rectangle by northwest and southeast corners. 37 + \brief Specifies a rectangle by northwest and southeast corners, given as CLLocationCoordinate2D.
38 38
39 \deprecated Note: northWest and southEast will change to northeast and southwest (note spelling and corner changes) after 0.5 to keep right-handed coordinate system 39 \deprecated Note: northWest and southEast will change to northeast and southwest (note spelling and corner changes) after 0.5 to keep right-handed coordinate system
40 */ 40 */
@@ -142,6 +142,7 @@ enum { @@ -142,6 +142,7 @@ enum {
142 - (id)initWithView: (UIView*) view; 142 - (id)initWithView: (UIView*) view;
143 - (id)initWithView: (UIView*) view 143 - (id)initWithView: (UIView*) view
144 tilesource:(id<RMTileSource>)newTilesource; 144 tilesource:(id<RMTileSource>)newTilesource;
  145 +/// designated initializer
145 - (id)initWithView:(UIView*)view 146 - (id)initWithView:(UIView*)view
146 tilesource:(id<RMTileSource>)tilesource 147 tilesource:(id<RMTileSource>)tilesource
147 centerLatLon:(CLLocationCoordinate2D)initialCenter 148 centerLatLon:(CLLocationCoordinate2D)initialCenter
@@ -150,15 +151,17 @@ enum { @@ -150,15 +151,17 @@ enum {
150 minZoomLevel:(float)minZoomLevel 151 minZoomLevel:(float)minZoomLevel
151 backgroundImage:(UIImage *)backgroundImage; 152 backgroundImage:(UIImage *)backgroundImage;
152 153
153 -/// these next 3 initializers subject to removal at any moment after 0.5 is released 154 +/// \deprecated subject to removal at any moment after 0.5 is released
154 - (id) initForView: (UIView*) view; 155 - (id) initForView: (UIView*) view;
  156 +/// \deprecated subject to removal at any moment after 0.5 is released
155 - (id) initForView: (UIView*) view WithLocation:(CLLocationCoordinate2D)latlong; 157 - (id) initForView: (UIView*) view WithLocation:(CLLocationCoordinate2D)latlong;
156 -// Designated initialiser 158 +/// \deprecated subject to removal at any moment after 0.5 is released
157 - (id)initForView:(UIView*)view WithTileSource:(id<RMTileSource>)tileSource WithRenderer:(RMMapRenderer*)renderer LookingAt:(CLLocationCoordinate2D)latlong; 159 - (id)initForView:(UIView*)view WithTileSource:(id<RMTileSource>)tileSource WithRenderer:(RMMapRenderer*)renderer LookingAt:(CLLocationCoordinate2D)latlong;
158 160
159 - (void)setFrame:(CGRect)frame; 161 - (void)setFrame:(CGRect)frame;
160 162
161 -- (void) didReceiveMemoryWarning; 163 +- (void)handleMemoryWarningNotification:(NSNotification *)notification;
  164 +- (void)didReceiveMemoryWarning;
162 165
163 - (void)moveToLatLong: (CLLocationCoordinate2D)latlong; 166 - (void)moveToLatLong: (CLLocationCoordinate2D)latlong;
164 - (void)moveToXYPoint: (RMXYPoint)aPoint; 167 - (void)moveToXYPoint: (RMXYPoint)aPoint;
@@ -154,21 +154,28 @@ @@ -154,21 +154,28 @@
154 markerManager = [[RMMarkerManager alloc] initWithContents:self]; 154 markerManager = [[RMMarkerManager alloc] initWithContents:self];
155 155
156 [newView setNeedsDisplay]; 156 [newView setNeedsDisplay];
  157 + [[NSNotificationCenter defaultCenter] addObserver:self
  158 + selector:@selector(handleMemoryWarningNotification:)
  159 + name:UIApplicationDidReceiveMemoryWarningNotification
  160 + object:nil];
  161 +
157 162
158 RMLog(@"Map contents initialised. view: %@ tileSource %@ renderer %@", newView, tileSource, renderer); 163 RMLog(@"Map contents initialised. view: %@ tileSource %@ renderer %@", newView, tileSource, renderer);
159 return self; 164 return self;
160 } 165 }
161 166
162 167
163 -/// deprecated at any moment after release 0.5 168 + /// deprecated at any moment after release 0.5
164 - (id) initForView: (UIView*) view 169 - (id) initForView: (UIView*) view
165 { 170 {
  171 + WarnDeprecated();
166 return [self initWithView:view]; 172 return [self initWithView:view];
167 } 173 }
168 174
169 /// deprecated at any moment after release 0.5 175 /// deprecated at any moment after release 0.5
170 - (id) initForView: (UIView*) view WithLocation:(CLLocationCoordinate2D)latlong 176 - (id) initForView: (UIView*) view WithLocation:(CLLocationCoordinate2D)latlong
171 { 177 {
  178 + WarnDeprecated();
172 LogMethod(); 179 LogMethod();
173 id<RMTileSource> _tileSource = [[RMOpenStreetMapsSource alloc] init]; 180 id<RMTileSource> _tileSource = [[RMOpenStreetMapsSource alloc] init];
174 RMMapRenderer *_renderer = [[RMCoreAnimationRenderer alloc] initWithContent:self]; 181 RMMapRenderer *_renderer = [[RMCoreAnimationRenderer alloc] initWithContent:self];
@@ -184,6 +191,7 @@ @@ -184,6 +191,7 @@
184 /// deprecated at any moment after release 0.5 191 /// deprecated at any moment after release 0.5
185 - (id) initForView: (UIView*) view WithTileSource: (id<RMTileSource>)_tileSource WithRenderer: (RMMapRenderer*)_renderer LookingAt:(CLLocationCoordinate2D)latlong 192 - (id) initForView: (UIView*) view WithTileSource: (id<RMTileSource>)_tileSource WithRenderer: (RMMapRenderer*)_renderer LookingAt:(CLLocationCoordinate2D)latlong
186 { 193 {
  194 + WarnDeprecated();
187 LogMethod(); 195 LogMethod();
188 if (![super init]) 196 if (![super init])
189 return nil; 197 return nil;
@@ -231,6 +239,10 @@ @@ -231,6 +239,10 @@
231 markerManager = [[RMMarkerManager alloc] initWithContents:self]; 239 markerManager = [[RMMarkerManager alloc] initWithContents:self];
232 240
233 [view setNeedsDisplay]; 241 [view setNeedsDisplay];
  242 + [[NSNotificationCenter defaultCenter] addObserver:self
  243 + selector:@selector(handleMemoryWarningNotification:)
  244 + name:UIApplicationDidReceiveMemoryWarningNotification
  245 + object:nil];
234 246
235 RMLog(@"Map contents initialised. view: %@ tileSource %@ renderer %@", view, tileSource, renderer); 247 RMLog(@"Map contents initialised. view: %@ tileSource %@ renderer %@", view, tileSource, renderer);
236 248
@@ -253,6 +265,7 @@ @@ -253,6 +265,7 @@
253 -(void) dealloc 265 -(void) dealloc
254 { 266 {
255 LogMethod(); 267 LogMethod();
  268 + [[NSNotificationCenter defaultCenter] removeObserver:self];
256 [imagesOnScreen cancelLoading]; 269 [imagesOnScreen cancelLoading];
257 [self setRenderer:nil]; 270 [self setRenderer:nil];
258 [imagesOnScreen release]; 271 [imagesOnScreen release];
@@ -269,6 +282,11 @@ @@ -269,6 +282,11 @@
269 [super dealloc]; 282 [super dealloc];
270 } 283 }
271 284
  285 +- (void)handleMemoryWarningNotification:(NSNotification *)notification
  286 +{
  287 + [self didReceiveMemoryWarning];
  288 +}
  289 +
272 - (void) didReceiveMemoryWarning 290 - (void) didReceiveMemoryWarning
273 { 291 {
274 LogMethod(); 292 LogMethod();
@@ -461,8 +461,9 @@ @@ -461,8 +461,9 @@
461 [delegate mapView:self didDragMarker:(RMMarker*)hit withEvent:event]; 461 [delegate mapView:self didDragMarker:(RMMarker*)hit withEvent:event];
462 return; 462 return;
463 } else if (_delegateHasDragMarkerPosition){ 463 } else if (_delegateHasDragMarkerPosition){
464 - //This else portion only exists to maintain compatability with old versions. SHOULD be removed after .5 tarball  
465 - [delegate dragMarkerPosition:(RMMarker*)hit onMap:self position:[[[event allTouches] anyObject]locationInView:self]]; 464 + //This else portion only exists to maintain compatability with old versions. SHOULD be removed after .5 tarball
  465 + RMLog(@"WARNING: dragMarkerPosition:onMap:position: has been deprecated. Switch to didDragMarker:");
  466 + [delegate dragMarkerPosition:(RMMarker*)hit onMap:self position:[[[event allTouches] anyObject]locationInView:self]];
466 return; 467 return;
467 } 468 }
468 } 469 }
@@ -471,6 +472,7 @@ @@ -471,6 +472,7 @@
471 472
472 if ([hit isKindOfClass: [RMMarker class]]) { 473 if ([hit isKindOfClass: [RMMarker class]]) {
473 if (_delegateHasDragMarkerPosition) { 474 if (_delegateHasDragMarkerPosition) {
  475 + RMLog(@"WARNING: dragMarkerPosition:onMap:position: has been deprecated. Switch to didDragMarker:");
474 [delegate dragMarkerPosition:(RMMarker*)hit onMap:self position:[[[event allTouches] anyObject]locationInView:self]]; 476 [delegate dragMarkerPosition:(RMMarker*)hit onMap:self position:[[[event allTouches] anyObject]locationInView:self]];
475 return; 477 return;
476 } 478 }
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 32
33 +(RMTileImage*) bestProxyFor: (RMTile) t 33 +(RMTileImage*) bestProxyFor: (RMTile) t
34 { 34 {
  35 + WarnDeprecated();
35 return nil; 36 return nil;
36 } 37 }
37 38
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 #import <Foundation/Foundation.h> 28 #import <Foundation/Foundation.h>
29 #import "RMTileImage.h" 29 #import "RMTileImage.h"
30 30
31 -/// a tile image loaded from a URL 31 +/// RMTileImage subclass: a tile image loaded from a URL.
32 @interface RMWebTileImage : RMTileImage { 32 @interface RMWebTileImage : RMTileImage {
33 /// Before image is completely loaded a proxy image can be used. 33 /// Before image is completely loaded a proxy image can be used.
34 /// This will typically be a boilerplate image or a zoomed in or zoomed out version of another image. 34 /// This will typically be a boilerplate image or a zoomed in or zoomed out version of another image.
@@ -11,12 +11,13 @@ @@ -11,12 +11,13 @@
11 #if DEBUG 11 #if DEBUG
12 #define RMLog(args...) NSLog( @"%@", [NSString stringWithFormat: args]) 12 #define RMLog(args...) NSLog( @"%@", [NSString stringWithFormat: args])
13 #define LogMethod() NSLog(@"%s logged method call: -[%@ %s] (line %d)", _cmd, self, _cmd, __LINE__) 13 #define LogMethod() NSLog(@"%s logged method call: -[%@ %s] (line %d)", _cmd, self, _cmd, __LINE__)
14 - 14 +#define WarnDeprecated() NSLog(@"***** WARNING: %s deprecated method call: -[%@ %s] (line %d)", _cmd, self, _cmd, __LINE__)
15 #else 15 #else
16 // DEBUG not defined: 16 // DEBUG not defined:
17 17
18 #define RMLog(args...) // do nothing. 18 #define RMLog(args...) // do nothing.
19 #define LogMethod() 19 #define LogMethod()
  20 +#define WarnDeprecated()
20 #define NS_BLOCK_ASSERTIONS 1 21 #define NS_BLOCK_ASSERTIONS 1
21 #endif 22 #endif
22 23