Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 1.31 KB

MakeDestination.md

File metadata and controls

58 lines (46 loc) · 1.31 KB

Make Destination

If you only want to get the destination, use makeDestination, and prepare the destination in block.

Swift Sample:

///time service's interface
protocol TimeServiceInput {
    func currentTimeString() -> String
}
class TestViewController: UIViewController {
    @IBOutlet weak var timeLabel: UILabel!
    
    func callTimeService() {
        //Get service for TimeServiceInput
        let timeService = Router.makeDestination(
            to: RoutableService<TimeServiceInput>(),
            preparation: { destination in
            //Prepare the service
        })
        //Call service
        timeLabel.text = timeService.currentTimeString()
    }
}
Objective-C Sample
///time service's interface
@protocol TimeServiceInput <ZIKServiceRoutable>
- (NSString *)currentTimeString;
@end
@interface TestViewController ()
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@end

@implementation TestViewController

- (void)callTimeService {
   //Get service for TimeServiceInput
   id<TimeServiceInput> timeService = [ZIKRouterToService(TimeServiceInput) makeDestination];
   //Call service
   self.timeLabel.text = [timeService currentTimeString];    
}

Next section: Error Handle