• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. title:: clang-tidy - google-objc-avoid-nsobject-new
2
3google-objc-avoid-nsobject-new
4==============================
5
6Finds calls to ``+new`` or overrides of it, which are prohibited by the
7Google Objective-C style guide.
8
9The Google Objective-C style guide forbids calling ``+new`` or overriding it in
10class implementations, preferring ``+alloc`` and ``-init`` methods to
11instantiate objects.
12
13An example:
14
15.. code-block:: objc
16
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:: objc
23
24  NSDate *now = [NSDate date];
25  Foo *bar = [[Foo alloc] init];
26
27This check corresponds to the Google Objective-C Style Guide rule
28`Do Not Use +new
29<https://google.github.io/styleguide/objcguide.html#do-not-use-new>`_.
30