TKTripsManager

@interface TKTripsManager : NSObject

A working manager used to work with Trip objects.

  • Shared Trips managing instance.

    Declaration

    Objective-C

    @property (readonly, strong, atomic, class)
        TKTripsManager *_Nonnull sharedManager;

    Swift

    class var shared: TKTripsManager { get }
  • Main getter method to get a TKTrip object.

    Declaration

    Objective-C

    - (nullable TKTrip *)tripWithID:(nonnull NSString *)tripID;

    Swift

    func trip(withID tripID: String) -> TKTrip?

    Parameters

    tripID

    An ID of a Trip.

    Return Value

    Fully-loaded TKTrip object.

  • Method used to get a light TKTripInfo object.

    Declaration

    Objective-C

    - (nullable TKTripInfo *)infoForTripWithID:(nonnull NSString *)tripID;

    Swift

    func infoForTrip(withID tripID: String) -> TKTripInfo?

    Parameters

    tripID

    An ID of a Trip.

    Return Value

    TKTripInfo object.

  • A method used to get all locally stored Trips.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTrip *> *)allTrips;

    Swift

    func allTrips() -> [TKTrip]

    Return Value

    An array of TKTrip objects.

  • A method used to get an info of all locally stored Trips.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)allTripInfos;

    Swift

    func allTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all upcoming Trips.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)upcomingTripInfos;

    Swift

    func upcomingTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all past Trips.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)pastTripInfos;

    Swift

    func pastTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all future Trips.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)futureTripInfos;

    Swift

    func futureTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all Trips in a specific year.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)tripInfosInYear:(NSInteger)year;

    Swift

    func tripInfos(inYear year: Int) -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all Trips with no date set.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)unscheduledTripInfos;

    Swift

    func unscheduledTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of all Trips marked as deleted.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)deletedTripInfos;

    Swift

    func deletedTripInfos() -> [TKTripInfo]

    Return Value

    An array of TKTripInfo objects.

  • A method used to get an info of Trips planned in a specified date range.

    Declaration

    Objective-C

    - (nonnull NSArray<TKTripInfo *> *)
    tripInfosForStartDate:(nullable NSDate *)startDate
                  endDate:(nullable NSDate *)endDate
       includeOverlapping:(BOOL)includeOverlapping;

    Swift

    func tripInfos(forStart startDate: Date?, end endDate: Date?, includeOverlapping: Bool) -> [TKTripInfo]

    Parameters

    startDate

    A start date to filter the Trips with. Optional.

    endDate

    An end date to filter the Trips with. Optional.

    includeOverlapping

    A flag indicating whether the Trips which overlap the given bounds in any way should be included as well.

    Return Value

    An array of TKTripInfo objects.

  • A method used to get a list of years where some Trip is planned.

    Declaration

    Objective-C

    - (nonnull NSArray<NSNumber *> *)yearsOfActiveTrips;

    Swift

    func yearsOfActiveTrips() -> [NSNumber]

    Return Value

    An array of NSNumbers representing years with some Trip planned.

  • A method used to save a locally created or modified Trip.

    Declaration

    Objective-C

    - (BOOL)saveTrip:(nonnull TKTrip *)trip;

    Swift

    func save(_ trip: TKTrip) -> Bool

    Parameters

    trip

    TKTrip instance to save.

    Return Value

    A boolean value indicating whether the saving operation was successful.

  • A method used to fetch a specific Trip from the API.

    Declaration

    Objective-C

    - (void)fetchTripWithID:(nonnull NSString *)tripID
                 completion:(nonnull void (^)(TKTrip *_Nullable,
                                              NSError *_Nullable))completion;

    Swift

    func fetchTrip(withID tripID: String, completion: @escaping (TKTrip?, Error?) -> Void)

    Parameters

    tripID

    ID of the Trip to fetch.

    completion

    Fetched Trip object or an error.

  • A method used to permanently wipe the Trips marked as deleted.

    Declaration

    Objective-C

    - (void)emptyTrashWithCompletion:
        (nonnull void (^)(NSArray<NSString *> *_Nullable,
                          NSError *_Nullable))completion;

    Swift

    func emptyTrash(completion: @escaping ([String]?, Error?) -> Void)

    Parameters

    completion

    Completion block with a result or an error.