Swift how to set restorationIdentifier in extension to static variable
up vote
-1
down vote
favorite
I need static variable identifier to UIViewController that gets self Storyboard ID
extension UIViewController {
static var identifier: String {
return self.restorationIdentifier
}
}
so I can do MyOwnViewController.identifier from other classes
ios swift extension-methods
add a comment |
up vote
-1
down vote
favorite
I need static variable identifier to UIViewController that gets self Storyboard ID
extension UIViewController {
static var identifier: String {
return self.restorationIdentifier
}
}
so I can do MyOwnViewController.identifier from other classes
ios swift extension-methods
Why not useMyOwnViewController.restorationIdentifier?
– Mike Taverne
Nov 21 at 21:05
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
It isn't clear what you are trying to achieve; TherestorationIdentifer(and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define aUIViewControllersubclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.
– Paulw11
Nov 21 at 21:42
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I need static variable identifier to UIViewController that gets self Storyboard ID
extension UIViewController {
static var identifier: String {
return self.restorationIdentifier
}
}
so I can do MyOwnViewController.identifier from other classes
ios swift extension-methods
I need static variable identifier to UIViewController that gets self Storyboard ID
extension UIViewController {
static var identifier: String {
return self.restorationIdentifier
}
}
so I can do MyOwnViewController.identifier from other classes
ios swift extension-methods
ios swift extension-methods
asked Nov 21 at 21:03
Serj Semenov
236
236
Why not useMyOwnViewController.restorationIdentifier?
– Mike Taverne
Nov 21 at 21:05
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
It isn't clear what you are trying to achieve; TherestorationIdentifer(and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define aUIViewControllersubclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.
– Paulw11
Nov 21 at 21:42
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54
add a comment |
Why not useMyOwnViewController.restorationIdentifier?
– Mike Taverne
Nov 21 at 21:05
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
It isn't clear what you are trying to achieve; TherestorationIdentifer(and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define aUIViewControllersubclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.
– Paulw11
Nov 21 at 21:42
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54
Why not use
MyOwnViewController.restorationIdentifier?– Mike Taverne
Nov 21 at 21:05
Why not use
MyOwnViewController.restorationIdentifier?– Mike Taverne
Nov 21 at 21:05
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
It isn't clear what you are trying to achieve; The
restorationIdentifer (and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define a UIViewController subclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.– Paulw11
Nov 21 at 21:42
It isn't clear what you are trying to achieve; The
restorationIdentifer (and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define a UIViewController subclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.– Paulw11
Nov 21 at 21:42
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53420438%2fswift-how-to-set-restorationidentifier-in-extension-to-static-variable%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
Why not use
MyOwnViewController.restorationIdentifier?– Mike Taverne
Nov 21 at 21:05
cause I don't need property of my object in that class, I need a static variable
– Serj Semenov
Nov 21 at 21:10
It isn't clear what you are trying to achieve; The
restorationIdentifer(and a Storyboard ID if it was exposed as a property, which it isn't) has a per-instance value, so it doesn't make sense to try and evaluate it in a class context. You can define aUIViewControllersubclass or a protocol (which is more Swifty) that your view controllers adopt in order to expose a property that you need.– Paulw11
Nov 21 at 21:42
seems clear to me, tnx
– Serj Semenov
Nov 21 at 21:54