Reputation: 57
I have something like
@property(nonatomic,retain) UIImageView *whiteBfFillUp;
@end
@synthesize locationManager;
I am new to swift coding. Can anyone tell me the equivalent code in swift.
Upvotes: 0
Views: 1781
Reputation: 26385
There is no equivalent.
In Swift when you write a var
or let
in a class or struct declaration you already declaring a property.
Define properties to store values
This is what is written in Swift documentation.
If you are concerned about access control you can use private
or public
modifiers.
public var somePublicVariable = 0
If you'd like to override properties such as you did in Objective-C you will find useful properties observers such as didSet{}
willSet{}
.
If you need a a readonly properties you can make the setter private.
public private(set) var hours = 0
Upvotes: 3
Reputation: 7549
If you are only looking for equivalent of property, then you just need to create your class level variables. All class level variables are by default 'strong' or 'retain'. If, however, you want them to be weak then use weak
.
This would be something like
var whiteBfFillUp: UIImageView? = nil
The ?
at the end means that this is an optional type. If it's not, you would need to assign it some value in the init method, or right there.
Upvotes: 1