Swift Syntax for Objective C [closed]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
In Obj C I created a property
@property(nonatomic) UILabel *subscriptionText;
Then I created a setter method for that property UILabel. like below
-(UILabel *)subscriptionText{
if (!_subscriptionText) {
_subscriptionText = [UILabel new];
_subscriptionText.translatesAutoresizingMaskIntoConstraints = NO;
_subscriptionText.textAlignment = NSTextAlignmentJustified;
}
return _subscriptionText;
}
then In viewdidload I add this view by
[self.view addSubview:self.subscriptionText];
How can I do this same scenario in Swift 4.2.
ios objective-c swift
closed as too broad by matt, Gereon, Hardik Thakkar, vikingosegundo, rmaddy Nov 17 '18 at 16:14
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
In Obj C I created a property
@property(nonatomic) UILabel *subscriptionText;
Then I created a setter method for that property UILabel. like below
-(UILabel *)subscriptionText{
if (!_subscriptionText) {
_subscriptionText = [UILabel new];
_subscriptionText.translatesAutoresizingMaskIntoConstraints = NO;
_subscriptionText.textAlignment = NSTextAlignmentJustified;
}
return _subscriptionText;
}
then In viewdidload I add this view by
[self.view addSubview:self.subscriptionText];
How can I do this same scenario in Swift 4.2.
ios objective-c swift
closed as too broad by matt, Gereon, Hardik Thakkar, vikingosegundo, rmaddy Nov 17 '18 at 16:14
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
-(UILabel *)subscriptionText;
is a getter method.
– Badhan Ganesh
Nov 17 '18 at 7:11
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15
add a comment |
In Obj C I created a property
@property(nonatomic) UILabel *subscriptionText;
Then I created a setter method for that property UILabel. like below
-(UILabel *)subscriptionText{
if (!_subscriptionText) {
_subscriptionText = [UILabel new];
_subscriptionText.translatesAutoresizingMaskIntoConstraints = NO;
_subscriptionText.textAlignment = NSTextAlignmentJustified;
}
return _subscriptionText;
}
then In viewdidload I add this view by
[self.view addSubview:self.subscriptionText];
How can I do this same scenario in Swift 4.2.
ios objective-c swift
In Obj C I created a property
@property(nonatomic) UILabel *subscriptionText;
Then I created a setter method for that property UILabel. like below
-(UILabel *)subscriptionText{
if (!_subscriptionText) {
_subscriptionText = [UILabel new];
_subscriptionText.translatesAutoresizingMaskIntoConstraints = NO;
_subscriptionText.textAlignment = NSTextAlignmentJustified;
}
return _subscriptionText;
}
then In viewdidload I add this view by
[self.view addSubview:self.subscriptionText];
How can I do this same scenario in Swift 4.2.
ios objective-c swift
ios objective-c swift
edited Nov 19 '18 at 3:36
Ruban4Axis
asked Nov 17 '18 at 6:38
Ruban4AxisRuban4Axis
348114
348114
closed as too broad by matt, Gereon, Hardik Thakkar, vikingosegundo, rmaddy Nov 17 '18 at 16:14
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by matt, Gereon, Hardik Thakkar, vikingosegundo, rmaddy Nov 17 '18 at 16:14
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
-(UILabel *)subscriptionText;
is a getter method.
– Badhan Ganesh
Nov 17 '18 at 7:11
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15
add a comment |
2
-(UILabel *)subscriptionText;
is a getter method.
– Badhan Ganesh
Nov 17 '18 at 7:11
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15
2
2
-(UILabel *)subscriptionText;
is a getter method.– Badhan Ganesh
Nov 17 '18 at 7:11
-(UILabel *)subscriptionText;
is a getter method.– Badhan Ganesh
Nov 17 '18 at 7:11
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15
add a comment |
1 Answer
1
active
oldest
votes
A lazy initialization is what you need.
lazy var subscriptionText: UILabel = {
let label = UILabel()
label.textAlignment = .justified
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
func viewDidLoad() {
super.viewDidLoad()
view.addSubview(subscriptionLabel)
// Label constraints
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A lazy initialization is what you need.
lazy var subscriptionText: UILabel = {
let label = UILabel()
label.textAlignment = .justified
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
func viewDidLoad() {
super.viewDidLoad()
view.addSubview(subscriptionLabel)
// Label constraints
}
add a comment |
A lazy initialization is what you need.
lazy var subscriptionText: UILabel = {
let label = UILabel()
label.textAlignment = .justified
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
func viewDidLoad() {
super.viewDidLoad()
view.addSubview(subscriptionLabel)
// Label constraints
}
add a comment |
A lazy initialization is what you need.
lazy var subscriptionText: UILabel = {
let label = UILabel()
label.textAlignment = .justified
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
func viewDidLoad() {
super.viewDidLoad()
view.addSubview(subscriptionLabel)
// Label constraints
}
A lazy initialization is what you need.
lazy var subscriptionText: UILabel = {
let label = UILabel()
label.textAlignment = .justified
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
func viewDidLoad() {
super.viewDidLoad()
view.addSubview(subscriptionLabel)
// Label constraints
}
edited Nov 17 '18 at 9:57
answered Nov 17 '18 at 7:24
Rakesha ShastriRakesha Shastri
7,78121735
7,78121735
add a comment |
add a comment |
2
-(UILabel *)subscriptionText;
is a getter method.– Badhan Ganesh
Nov 17 '18 at 7:11
In Swift Bro I am Asking
– Ruban4Axis
Nov 17 '18 at 7:15