CGRect rect = [self rectForMapRect:mapRect]; depraceted <p>I have this code here:</p> <pre><code>CGRect rect = [self rectForMapRect:mapRect]; </code></pre> <p>This gives me a deprecated warning. In order to keep things clean, I wanna make it with actual code, but I don't know how. Could anyone tell me how?</p> <p>Here is the whole bunch of code:</p> <pre><code>- (void)fillMapRect:(MKMapRect)mapRect context:(CGContextRef)context { CGMutablePathRef path = CGPathCreateMutable(); CGRect rect = [self rectForMapRect:mapRect]; CGPathMoveToPoint(path, nil, rect.origin.x, rect.origin.y); CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y); CGPathAddLineToPoint(path, nil, rect.origin.x + rect.size.width, rect.origin.y + rect.size.height); CGPathAddLineToPoint(path, nil, rect.origin.x, rect.origin.y + rect.size.height); CGPathCloseSubpath(path); CGContextAddPath(context, path); UIColor *overlayColor = [UIColor colorWithWhite:0.0 alpha:0.2]; CGContextSetFillColorWithColor(context, overlayColor.CGColor); CGContextDrawPath(context, kCGPathFillStroke); CGPathRelease(path); </code></pre>