Search code examples
iosobjective-cinstance-variablesxcode11.4

Xcode 11.4 not allowing to use instance variable


i have Just In time property, which was working fine but now xcode 11.4 started complaining about it. please look at following code

- (UITextField *)searchTextField
{
    if (!_searchTextField)
    {
        _searchTextField = [self firstSubViewOfKindOfClass:[UITextField class]];
    }
    return _searchTextField;
}

Error :Use of undeclared identifier '_searchTextField'

i have a property defined for it like below

@property (nonatomic, strong) UITextField  *searchTextField;

Solution

  • You have a name clash. You cannot define a searchTextField because there already is a searchTextField (in iOS 13):

    https://developer.apple.com/documentation/uikit/uisearchbar/3175433-searchtextfield
    

    So you could just delete your code, as it isn't needed in iOS 13. Or if you need to support iOS 12 and earlier, you could give your property a different name that doesn't clash.