Skip to main content

All 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 ...
Jagen Kabali's user avatar
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 @...
srus2017's user avatar
  • 414
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 ...
Alan Hoo's user avatar
  • 455
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 { ...
Magic Bullet Dave's user avatar
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 ...
serhat sezer's user avatar
  • 1,354
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 ...
kasplat's user avatar
  • 1,187
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....
Alex Brashear's user avatar
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 ...
Danra's user avatar
  • 9,956
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 ...
user3307688's user avatar
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 ...
user1347149's user avatar
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 ...
Ra1nWarden's user avatar
  • 1,240
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 // ... @...
Goodsquirrel's user avatar
  • 1,514
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 ...
Lavi Avigdor's user avatar
  • 4,182
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 ...
Alex's user avatar
  • 1,605
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 ...
user2076774's user avatar

15 30 50 per page