| 1 |
.. title:: clang-tidy - objc-property-declaration |
| 2 |
|
| 3 |
objc-property-declaration |
| 4 |
========================= |
| 5 |
|
| 6 |
Finds property declarations in Objective-C files that do not follow the pattern |
| 7 |
of property names in Apple's programming guide. The property name should be |
| 8 |
in the format of Lower Camel Case. |
| 9 |
|
| 10 |
For code: |
| 11 |
|
| 12 |
.. code-block:: objc |
| 13 |
|
| 14 |
@property(nonatomic, assign) int LowerCamelCase; |
| 15 |
|
| 16 |
The fix will be: |
| 17 |
|
| 18 |
.. code-block:: objc |
| 19 |
|
| 20 |
@property(nonatomic, assign) int lowerCamelCase; |
| 21 |
|
| 22 |
The check will only fix 'CamelCase' to 'camelCase'. In some other cases we will |
| 23 |
only provide warning messages since the property name could be complicated. |
| 24 |
Users will need to come up with a proper name by their own. |
| 25 |
|
| 26 |
This check also accepts special acronyms as prefixes or suffixes. Such prefixes or suffixes |
| 27 |
will suppress the Lower Camel Case check according to the guide: |
| 28 |
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB |
| 29 |
|
| 30 |
For a full list of well-known acronyms: |
| 31 |
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE |
| 32 |
|
| 33 |
The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757 |
| 34 |
|
| 35 |
The check will also accept property declared in category with a prefix of |
| 36 |
lowercase letters followed by a '_' to avoid naming conflict. For example: |
| 37 |
|
| 38 |
.. code-block:: objc |
| 39 |
|
| 40 |
@property(nonatomic, assign) int abc_lowerCamelCase; |
| 41 |
|
| 42 |
The corresponding style rule: https://developer.apple.com/library/content/qa/qa1908/_index.html |