Skip to content

Commit 22045ae

Browse files
committed
Exclude Contacts usage from tvOS in code samples
1 parent 44e62ca commit 22045ae

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ _Forward geocoding_ takes a human-readable query, such as a place name or addres
5959

6060
```swift
6161
// main.swift
62-
import Contacts
62+
#if !os(tvOS)
63+
import Contacts
64+
#endif
6365

6466
let options = ForwardGeocodeOptions(query: "200 queen street")
6567

@@ -79,17 +81,21 @@ let task = geocoder.geocode(options: options) { (placemarks, attribution, error)
7981
print("\(coordinate.latitude), \(coordinate.longitude)")
8082
// 45.270093, -66.050985
8183

84+
#if !os(tvOS)
8285
let formatter = CNPostalAddressFormatter()
8386
print(formatter.stringFromPostalAddress(placemark.postalAddress))
8487
// 200 Queen St
8588
// Saint John New Brunswick E2L 2X1
8689
// Canada
90+
#endif
8791
}
8892
```
8993

9094
```objc
9195
// main.m
96+
#if !TARGET_OS_TV
9297
@import Contacts;
98+
#endif
9399

94100
MBForwardGeocodeOptions *options = [[MBForwardGeocodeOptions alloc] initWithQuery:@"200 queen street"];
95101

@@ -112,11 +118,13 @@ NSURLSessionDataTask *task = [geocoder geocodeWithOptions:options
112118
NSLog(@"%f, %f", coordinate.latitude, coordinate.longitude);
113119
// 45.270093, -66.050985
114120

121+
#if !TARGET_OS_TV
115122
CNPostalAddressFormatter *formatter = [[CNPostalAddressFormatter alloc] init];
116123
NSLog(@"%@", [formatter stringFromPostalAddress:placemark.postalAddress]);
117124
// 200 Queen St
118125
// Saint John New Brunswick E2L 2X1
119126
// Canada
127+
#endif
120128
}];
121129
```
122130

0 commit comments

Comments
 (0)