Jagen Kabali
Jagen Kabali

Reputation: 27

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 as lazy var type. So, Share your ideas, if you had faced in anywhere the same. And I tried with below link already,



Reference Link

Upvotes: 0

Views: 298

Answers (1)

ssowri1
ssowri1

Reputation: 1317

Use the below code snippet, To get rid of such that issue.

   UIView *accesView = [[UIview alloc]init];
-(UIView *) inputAccessoryView {
    if (_accesView == nil) {
        _accesView = [[UIView alloc]init];
        inputView *view = [[[NSBundle mainBundle] loadNibNamed:@"inputView" owner:nil options:nil] firstObject];
        _accesView = view;
    }
    return _accesView;
}

Upvotes: -1

Related Questions