30 lines · plain
1.. title:: clang-tidy - google-objc-avoid-nsobject-new2 3google-objc-avoid-nsobject-new4==============================5 6Finds calls to ``+new`` or overrides of it, which are prohibited by the7Google Objective-C style guide.8 9The Google Objective-C style guide forbids calling ``+new`` or overriding it in10class implementations, preferring ``+alloc`` and ``-init`` methods to11instantiate objects.12 13An example:14 15.. code-block:: objc16 17 NSDate *now = [NSDate new];18 Foo *bar = [Foo new];19 20Instead, code should use ``+alloc``/``-init`` or class factory methods.21 22.. code-block:: objc23 24 NSDate *now = [NSDate date];25 Foo *bar = [[Foo alloc] init];26 27This check corresponds to the Google Objective-C Style Guide rule28`Do Not Use +new29<https://google.github.io/styleguide/objcguide.html#do-not-use-new>`_.30