All Questions
Tagged with lazy-initialization objective-c
26 questions
0
votes
1
answer
300
views
How to Initialise view as lazy var in Objective C
Well! I had worked with Lazy var in swift. Nevertheless, I want to use the lazy var type to my accessory view in one of my Objective C projects. I couldn’t find the exact answer for declaring UIView ...
0
votes
1
answer
140
views
Thread Safety - lazily initialized property getter - Objective C
Suppose if I want to implement both getter and setter I will do like this -
@interface Person () {
dispatch_queue_t _myConcurrentQueue;
}
@property (nonatomic, copy) NSString *personName;
@end
@...
0
votes
0
answers
79
views
How loadNibNamed function set an IBOutlet property of an UIController
Really new to iOS programming and read some codes in tutorial that really confused.
-(UIView*)headerView{
if(!_headerView) {
[[NSBundle mainBundle] loadNibNamed:@"HeaderView1" owner:self ...
4
votes
2
answers
2k
views
Atomic property with custom getter
I have a class with a property declared as:
@property (nonatomic, strong) NSMutableArray *links;
I want to lazily instantiate it so have the following custom getter:
- (NSMutableArray *)links {
...
0
votes
0
answers
222
views
UITableViewCell lazy instantiation cell
I have a UITableView called UserProductViewController and this table view used for two purpose "create and edit" some data. When user click "edit button" open this UserProductViewController edit mode ...
1
vote
0
answers
500
views
converting Objective-C lazy instantiation with side effects to Swift
I converted the Objective-C app Dropit from the Stanford CS193P course to Swift. The original code is located at:
http://web.stanford.edu/class/cs193p/cgi-bin/drupal/
There are multiple uses of lazy ...
1
vote
1
answer
77
views
Crash with lazy initialization
I am having problems with lazily initializing an image. In my view controller I am trying to say if the image has not been retrieved from URL, then load it.
- (UIImage *)image {
if (!self....
1
vote
1
answer
584
views
How to implement lazy evaluation of objective-C property which may be nil?
In objective-C, how can I properly implement lazy evaluation of a property which may be nil?
The usual practice is demonstrated below, however it does not work properly for properties which may be ...
3
votes
1
answer
453
views
Why do the courses at Stanford use the lazy initialisation? [duplicate]
Why does the course at Stanford use the lazy initialization for all getters?
Is this correct? Does it have any real advantage?
One advantage (for me) is that the init method can become much shorter ...
0
votes
1
answer
291
views
lazy instantiation UIImageView
I am trying to look at most efficient way of initialising UIIMageViews within a custom UIView class which is placed within a Custom UITableCell
My custom view has more than one button. In essence I ...
5
votes
2
answers
8k
views
How to initialize a property in iOS UITableViewController
I am working on a UITableViewController
@interface GinkgoDeliveryOrdersTableViewController : UITableViewController
@property PFQuery * query;
@property NSArray * products;
@end
How shall I ...
9
votes
2
answers
10k
views
Overriding property getters with lazy loading in Objective-C
I usually lazy instantiate my @property objects in their getter methods like this:
@interface MyGenericClass : UIViewController
@property(nonatomic, readonly) UIImageView *infoImageView
// ...
@...
3
votes
2
answers
2k
views
In objective C lazy instantiation, why don't we touch the setter?
In objective C, its common practice to instantiate internal class arrays (and the like) in a lazy manner.
So if you call on the getter, it first checks if the array isn't nil, and allocates memory ...
1
vote
2
answers
186
views
Frequent Allocation/Deallocation of an Object - Objective -C
I'm using "Requests Buffer" class as a @property of my main Model class. There is a lazy instantiation for the buffer and when there are no items to process in the buffer model sets it to nil. I'm ...
0
votes
1
answer
620
views
Lazy instantiation in Setter or getter?
Hi when you do lazy instantiation should you do it in the setter or getter? I have heard that you do it in the getter but what if the property is set before it is called for by a getter? Would that ...