Skip to content

Commit

Permalink
Examples update
Browse files Browse the repository at this point in the history
  • Loading branch information
username0x0a committed Jan 22, 2020
1 parent 19829b0 commit d5c772b
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions Documentation/content_pages/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@
// Get and print the name and description of Eiffel Tower (poi:530)
TKPlacesManager *manager = [[TravelKit sharedKit] places];

[manager detailedPlaceWithID: @"poi:530" completion:^(TKDetailedPlace * _Nullable place, NSError * _Nullable error) {
[manager detailedPlaceWithID:@"poi:530" completion:^(TKDetailedPlace * _Nullable place, NSError * _Nullable error) {
if (place) {
NSString *description = place.detail.fullDescription.text;
if (description) NSLog(@"Description of %@ is: %@", place.name, description);
else NSLog(@"Something went wrong :/");
NSLog(@"Description of %@ is: %@", place.name, description);
}
else NSLog(@"Something went wrong :/");
}];
```
```swift
// Get and print the name and description of Eiffel Tower (poi:530)
TravelKit.shared.places.detailedPlace(withID: "poi:530", completion:{ (detailedPlace, err) in
if let description = detailedPlace?.detail?.fullDescription?.text {
print("Description of \(detailedPlace.name) is: \(description)")
}
else {
TravelKit.shared.places.detailedPlace(withID: "poi:530") { (detailedPlace, error) in
if let place = detailedPlace, let desc = place.detail?.fullDescription?.text {
print("Description of \(place.name) is:\n\n\(desc)")
} else {
print("Something went wrong :/")
}
})
}
```

### Get place media
Expand All @@ -50,7 +49,7 @@ TKPlacesManager *manager = [[TravelKit sharedKit] places];
```swift
// Besides main media, we can get all media available for a certain place
TravelKit.shared.places.mediaForPlace(withID: "poi:530", completion: { (media, err) in
TravelKit.shared.places.mediaForPlace(withID: "poi:530") { (media, err) in
if let media = media, let first = media.first {
// Print medium title if it has one
for m in media {
Expand All @@ -59,7 +58,7 @@ TravelKit.shared.places.mediaForPlace(withID: "poi:530", completion: { (media, e
// To get the actual image from URL with certain size, we use method in TKMedium
first.displayableImageURL(for: CGSize(width: first.width, height: first.height))
}
})
}
```

## Tours module
Expand Down Expand Up @@ -93,7 +92,7 @@ query.minimalDuration = 3600
query.count = 12
// Perform query and print a message containing tour's title
TravelKit.shared._tours.tours(for: query) { (tours, err) in
TravelKit.shared.tours.tours(for: query) { (tours, err) in
if let tours = tours {
for tour in tours {
print("\(tour.title)")
Expand All @@ -102,18 +101,18 @@ TravelKit.shared._tours.tours(for: query) { (tours, err) in
}
```

## Favorites module
## Favourites module

### Favorite & unfavorite places
### Favourite & unfavourite places

```objc
TKFavoritesManager *manager = [[TravelKit sharedKit] favorites];
// Add Eiffel Tower to favorites
[manager updateFavoritePlaceID:@"poi:530" setFavorite:TRUE];
[manager updateFavoritePlaceID:@"poi:530" setFavorite:YES];
// Get your favorites and print their IDs
NSLog(@"%@", [manager favoritePlaceIDs]);
// Remove Eiffel Tower from favorites
[manager updateFavoritePlaceID:@"poi:530" setFavorite:FALSE];
[manager updateFavoritePlaceID:@"poi:530" setFavorite:NO];
```
```swift
Expand Down

0 comments on commit d5c772b

Please sign in to comment.