-1

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

  • 1
    Possible duplicate of [Lazy instantiation in Objective-C/ iPhone development](https://stackoverflow.com/questions/11769562/lazy-instantiation-in-objective-c-iphone-development) – Amin Negm-Awad Mar 21 '19 at 07:49
  • 1
    You are referring to another Q about lazy instantiation. What's your actual problem with it? Moreover, a general "sharing your ideas" is in the scope of forums, but not in the scope of SO. – Amin Negm-Awad Mar 21 '19 at 07:50

1 Answers1

0

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;
}
ssowri1
  • 1,299
  • 2
  • 14
  • 31