Routing Design Pattern In Objective-C
up vote
-2
down vote
favorite
I have found good tutorial on Routing design pattern at Swift
Can some one explain it or create it in Objective-C?
GOAL
To jump from one view controller to any other view and vice - versa
Means user can jump at any view to any view using this pattern
https://medium.com/commencis/routing-with-mvvm-on-ios-f22d021ad2b2
ios objective-c iphone
add a comment |
up vote
-2
down vote
favorite
I have found good tutorial on Routing design pattern at Swift
Can some one explain it or create it in Objective-C?
GOAL
To jump from one view controller to any other view and vice - versa
Means user can jump at any view to any view using this pattern
https://medium.com/commencis/routing-with-mvvm-on-ios-f22d021ad2b2
ios objective-c iphone
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I have found good tutorial on Routing design pattern at Swift
Can some one explain it or create it in Objective-C?
GOAL
To jump from one view controller to any other view and vice - versa
Means user can jump at any view to any view using this pattern
https://medium.com/commencis/routing-with-mvvm-on-ios-f22d021ad2b2
ios objective-c iphone
I have found good tutorial on Routing design pattern at Swift
Can some one explain it or create it in Objective-C?
GOAL
To jump from one view controller to any other view and vice - versa
Means user can jump at any view to any view using this pattern
https://medium.com/commencis/routing-with-mvvm-on-ios-f22d021ad2b2
ios objective-c iphone
ios objective-c iphone
edited 16 hours ago
Moritz
56.9k19131184
56.9k19131184
asked 2 days ago
9to5ios
3,12522051
3,12522051
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago
add a comment |
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
-1
down vote
For this kind of flow I use flow coordinators. It just means that in the view controller itself you don't have a hardcoded destination view controller, you just call some delegate (I call him flowDelegate
) and this delegate decides what to do next. The sample call would look like this
Obj-C:
@class HomeViewController;
@protocol HomeFlowDelegate
- (void)didTapRegistrationButtonInViewController:(HomeViewController*)viewController;
@end
@interface HomeViewController: UIViewController
@property (nonatomic,weak) id<HomeFlowDelegate> flowDelegate;
@end
@implementation HomeViewController
- (void)registrationButtonTapped {
[self.flowDelegate didTapRegistrationButtonInViewController:self];
}
@end
Swift:
protocol HomeFlowDelegate {
func didTapRegistrationButton(in viewController: HomeViewController)
}
class HomeViewController: ViewController {
weak var flowDelegate: HomeFlowDelegate?
func registrationButtonTapped() {
flowDelegate?.didTapRegistrationButton(in: self)
}
}
The flow delegate can than decide e.g. whether to push new screen or present it modally or do whatever flow would be appropriate.
This approach means that view controllers are independent and can be reused anywhere in the app. You just have to make sure that when a view controller comes on screen it has a flowDelegate
assigned.
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
For this kind of flow I use flow coordinators. It just means that in the view controller itself you don't have a hardcoded destination view controller, you just call some delegate (I call him flowDelegate
) and this delegate decides what to do next. The sample call would look like this
Obj-C:
@class HomeViewController;
@protocol HomeFlowDelegate
- (void)didTapRegistrationButtonInViewController:(HomeViewController*)viewController;
@end
@interface HomeViewController: UIViewController
@property (nonatomic,weak) id<HomeFlowDelegate> flowDelegate;
@end
@implementation HomeViewController
- (void)registrationButtonTapped {
[self.flowDelegate didTapRegistrationButtonInViewController:self];
}
@end
Swift:
protocol HomeFlowDelegate {
func didTapRegistrationButton(in viewController: HomeViewController)
}
class HomeViewController: ViewController {
weak var flowDelegate: HomeFlowDelegate?
func registrationButtonTapped() {
flowDelegate?.didTapRegistrationButton(in: self)
}
}
The flow delegate can than decide e.g. whether to push new screen or present it modally or do whatever flow would be appropriate.
This approach means that view controllers are independent and can be reused anywhere in the app. You just have to make sure that when a view controller comes on screen it has a flowDelegate
assigned.
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
add a comment |
up vote
-1
down vote
For this kind of flow I use flow coordinators. It just means that in the view controller itself you don't have a hardcoded destination view controller, you just call some delegate (I call him flowDelegate
) and this delegate decides what to do next. The sample call would look like this
Obj-C:
@class HomeViewController;
@protocol HomeFlowDelegate
- (void)didTapRegistrationButtonInViewController:(HomeViewController*)viewController;
@end
@interface HomeViewController: UIViewController
@property (nonatomic,weak) id<HomeFlowDelegate> flowDelegate;
@end
@implementation HomeViewController
- (void)registrationButtonTapped {
[self.flowDelegate didTapRegistrationButtonInViewController:self];
}
@end
Swift:
protocol HomeFlowDelegate {
func didTapRegistrationButton(in viewController: HomeViewController)
}
class HomeViewController: ViewController {
weak var flowDelegate: HomeFlowDelegate?
func registrationButtonTapped() {
flowDelegate?.didTapRegistrationButton(in: self)
}
}
The flow delegate can than decide e.g. whether to push new screen or present it modally or do whatever flow would be appropriate.
This approach means that view controllers are independent and can be reused anywhere in the app. You just have to make sure that when a view controller comes on screen it has a flowDelegate
assigned.
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
add a comment |
up vote
-1
down vote
up vote
-1
down vote
For this kind of flow I use flow coordinators. It just means that in the view controller itself you don't have a hardcoded destination view controller, you just call some delegate (I call him flowDelegate
) and this delegate decides what to do next. The sample call would look like this
Obj-C:
@class HomeViewController;
@protocol HomeFlowDelegate
- (void)didTapRegistrationButtonInViewController:(HomeViewController*)viewController;
@end
@interface HomeViewController: UIViewController
@property (nonatomic,weak) id<HomeFlowDelegate> flowDelegate;
@end
@implementation HomeViewController
- (void)registrationButtonTapped {
[self.flowDelegate didTapRegistrationButtonInViewController:self];
}
@end
Swift:
protocol HomeFlowDelegate {
func didTapRegistrationButton(in viewController: HomeViewController)
}
class HomeViewController: ViewController {
weak var flowDelegate: HomeFlowDelegate?
func registrationButtonTapped() {
flowDelegate?.didTapRegistrationButton(in: self)
}
}
The flow delegate can than decide e.g. whether to push new screen or present it modally or do whatever flow would be appropriate.
This approach means that view controllers are independent and can be reused anywhere in the app. You just have to make sure that when a view controller comes on screen it has a flowDelegate
assigned.
For this kind of flow I use flow coordinators. It just means that in the view controller itself you don't have a hardcoded destination view controller, you just call some delegate (I call him flowDelegate
) and this delegate decides what to do next. The sample call would look like this
Obj-C:
@class HomeViewController;
@protocol HomeFlowDelegate
- (void)didTapRegistrationButtonInViewController:(HomeViewController*)viewController;
@end
@interface HomeViewController: UIViewController
@property (nonatomic,weak) id<HomeFlowDelegate> flowDelegate;
@end
@implementation HomeViewController
- (void)registrationButtonTapped {
[self.flowDelegate didTapRegistrationButtonInViewController:self];
}
@end
Swift:
protocol HomeFlowDelegate {
func didTapRegistrationButton(in viewController: HomeViewController)
}
class HomeViewController: ViewController {
weak var flowDelegate: HomeFlowDelegate?
func registrationButtonTapped() {
flowDelegate?.didTapRegistrationButton(in: self)
}
}
The flow delegate can than decide e.g. whether to push new screen or present it modally or do whatever flow would be appropriate.
This approach means that view controllers are independent and can be reused anywhere in the app. You just have to make sure that when a view controller comes on screen it has a flowDelegate
assigned.
edited yesterday
answered 2 days ago
olejnjak
263212
263212
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
add a comment |
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
The question is clearly asking for an answer in Objective-C, not Swift.
– rmaddy
2 days ago
Added my approach in Obj-C
– olejnjak
yesterday
Added my approach in Obj-C
– olejnjak
yesterday
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350342%2frouting-design-pattern-in-objective-c%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The article code has nothing Swift specific e.g Tuples or generics. The explanation remains the same. The code is more or less a direct language syntax conversion.
– Warren Burton
2 days ago