Skip to content

Commit 7c5d471

Browse files
committed
Merge pull request #33 from mapbox/fb-assert-token
Assert that MapboxAccessToken has been set
2 parents bfc3ff5 + c5e2844 commit 7c5d471

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Geocoder Example/ViewController.m

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
@interface ViewController () <MKMapViewDelegate>
1212

13-
#pragma mark -
14-
#pragma mark Variables
13+
#pragma mark - Variables
1514

1615
@property (nonatomic) MKMapView *mapView;
1716
@property (nonatomic) UILabel *resultsLabel;
@@ -24,13 +23,14 @@ @interface ViewController () <MKMapViewDelegate>
2423

2524
@implementation ViewController
2625

27-
#pragma mark -
28-
#pragma mark Setup
26+
#pragma mark - Setup
2927

3028

3129
- (void)viewDidLoad {
3230
[super viewDidLoad];
3331

32+
NSAssert(![MapboxAccessToken isEqualToString:@"<# your Mapbox access token #>"], @"You must set `MapboxAccessToken` to your Mapbox access token.");
33+
3434
self.mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
3535
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
3636
self.mapView.delegate = self;
@@ -47,8 +47,7 @@ - (void)viewDidLoad {
4747
self.geocoder = [[MBGeocoder alloc] initWithAccessToken:MapboxAccessToken];
4848
}
4949

50-
#pragma mark -
51-
#pragma mark MKMapViewDelegate
50+
#pragma mark - MKMapViewDelegate
5251

5352
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
5453
[self.geocoder cancelGeocode];

Geocoder Example/ViewController.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ let MapboxAccessToken = "<# your Mapbox access token #>"
99

1010
class ViewController: UIViewController, MKMapViewDelegate {
1111

12-
// MARK: -
13-
// MARK: Variables
12+
// MARK: - Variables
1413

1514
var mapView: MKMapView!
1615
var resultsLabel: UILabel!
1716
// var geocoder: CLGeocoder!
1817
var geocoder: MBGeocoder!
1918

20-
// MARK: -
21-
// MARK: Setup
19+
// MARK: - Setup
2220

2321
override func viewDidLoad() {
2422
super.viewDidLoad()
23+
24+
assert(MapboxAccessToken != "<# your Mapbox access token #>", "You must set `MapboxAccessToken` to your Mapbox access token.")
2525

2626
mapView = MKMapView(frame: view.bounds)
2727
mapView.autoresizingMask = [ .FlexibleWidth, .FlexibleHeight ]
@@ -39,8 +39,7 @@ class ViewController: UIViewController, MKMapViewDelegate {
3939
geocoder = MBGeocoder(accessToken: MapboxAccessToken)
4040
}
4141

42-
// MARK: -
43-
// MARK: MKMapViewDelegate
42+
// MARK: - MKMapViewDelegate
4443

4544
func mapView(mapView: MKMapView, regionWillChangeAnimated animated: Bool) {
4645
geocoder.cancelGeocode()

0 commit comments

Comments
 (0)