在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak、循环引用、不能执行之类的警告。 有代码洁癖的孩子们很想消除他们, 今天就让我们来一次Fuck 警告!!
首先学会基本的语句
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
中间写出现警告的代码
#pragma clang diagnostic pop
这样就消除了方法弃用的警告!
同理, 大家可以在下边搜索到对应的警告, 这样 就可以把前边的字串填入上边的ignored的后边, 然后阔住你的代码, 就OK了
Semantic Warnings
Warning Message
-WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8
-WNSObject-attribute __attribute ((NSObject)) may be put on a typedef only, attribute is ignored
-Wabstract-vbase-init initializer for virtual base class %0 of abstract class %1 will never be used
-Waddress-of-array-temporary pointer is initialized by a temporary array, which will be destroyed at the end of the full-expression
-Warc-maybe-repeated-use-of-weak "weak %select{variable|property|implicit property|instance variable}0 %1 may be accessed multiple times in this %select{function|method|block|lambda}2 and may be unpredictably set to nil assign to a strong variable to keep the object alive
-Warc-non-pod-memaccess %select{destination for|source of}0 this %1 call is a pointer to ownership-qualified type %2
-Warc-performSelector-leaks performSelector may cause a leak because its selector is unknown
-Warc-repeated-use-of-weak "weak %select{variable|property|implicit property|instance variable}0 %1 is accessed multiple times in this %select{function|method|block|lambda}2 but may be unpredictably set to nil assign to a strong variable to keep the object alive
-Warc-retain-cycles capturing %0 strongly in this block is likely to lead to a retain cycle
-Warc-unsafe-retained-assign assigning retained object to unsafe property object will be released after assignment
-Warc-unsafe-retained-assign assigning %select{array literal|dictionary literal|numeric literal|boxed expression|should not happen|block literal}0 to a weak %select{property|variable}1 object will be released after assignment
-Warc-unsafe-retained-assign assigning retained object to %select{weak|unsafe_unretained}0 %select{property|variable}1 object will be released after assignment
-Warray-bounds array index %0 is past the end of the array (which contains %1 element%s2)
-Warray-bounds array index %0 is before the beginning of the array
-Warray-bounds ‘static‘ has no effect on zero-length arrays
-Warray-bounds array argument is too small contains %0 elements, callee requires at least %1
-Warray-bounds-pointer-arithmetic the pointer incremented by %0 refers past the end of the array (that contains %1 element%s2)
-Warray-bounds-pointer-arithmetic the pointer decremented by %0 refers before the beginning of the array
-Wassign-enum integer constant not in range of enumerated type %0
-Watomic-property-with-user-defined-accessor writable atomic property %0 cannot pair a synthesized %select{getter|setter}1 with a user defined %select{getter|setter}2
-Wattributes unknown attribute %0 ignored
-Wauto-var-id ‘auto‘ deduced as ‘id‘ in declaration of %0
-Wavailability unknown platform %0 in availability macro
-Wavailability overriding method %select{introduced after|deprecated before|obsoleted before}0 overridden method on %1 (%2 vs. %3)
-Wavailability availability does not match previous declaration
-Wavailability overriding method cannot be unavailable on %0 when its overridden method is available
-Wavailability feature cannot be %select{introduced|deprecated|obsoleted}0 in %1 version %2 before it was %select{introduced|deprecated|obsoleted}3 in version %4 attribute ignored
-Wbad-function-cast cast from function call of type %0 to non-matching type %1
-Wbitfield-constant-conversion implicit truncation from %2 to bitfield changes value from %0 to %1
-Wbitwise-op-parentheses ‘&‘ within ‘|‘
-Wbool-conversion "initialization of pointer of type %0 to null from a constant boolean " "expression
-Wbridge-cast %0 cannot bridge to %1
-Wbridge-cast %0 bridges to %1, not %2
-Wbuiltin-requires-header declaration of built-in function ‘%0‘ requires inclusion of the header stdio.h
-Wbuiltin-requires-header declaration of built-in function ‘%0‘ requires inclusion of the header setjmp.h
-Wbuiltin-requires-header declaration of built-in function ‘%0‘ requires inclusion of the header ucontext.h
-Wc++-compat %select{|empty }0%select{struct|union}1 has size 0 in C, %select{size 1|non-zero size}2 in C++
-Wc++11-compat explicit instantiation cannot be ‘inline‘
-Wc++11-compat explicit instantiation of %0 must occur at global scope
-Wc++11-compat explicit instantiation of %0 not in a namespace enclosing %1
-Wc++11-compat explicit instantiation of %q0 must occur in namespace %1
-Wc++11-narrowing constant expression evaluates to %0 which cannot be narrowed to type %1 in C++11
-Wc++11-narrowing type %0 cannot be narrowed to %1 in initializer list in C++11
-Wc++11-narrowing non-constant-expression cannot be narrowed from type %0 to %1 in initializer list in C++11
-Wc++98-c++11-compat type definition in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat use of this statement in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat init-captures.def warn_cxx11_compat_init_capture : Warning "initialized lambda captures are incompatible with C++ standards " "before C++1y
-Wc++98-c++11-compat variable declaration in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat constexpr function with no return statements is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat multiple return statements in constexpr function is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat variable templates are incompatible