iOS10中CAAnimationDelegate適配問題

Xcode8打開後出現swift

⚠️/Users/shuodao/Desktop/iOS-swift-daodaokefu/daodaokefu/popupViewController/LewPopupViewAnimationSpring.m:50:28: Assigning to 'id<CAAnimationDelegate> _Nullable' from incompatible type 'LewPopupViewAnimationSpring *const __strong'spa

出現警告雖然沒有什麼影響,可是新系統的出現仍是探究一下比較有意思,看着比較明顯是由於沒有聽從協議;對比iOS10 以前,CAAnimationDelegate只是基類的分類方法,是擴展。可是iOS10以後,CAAnimationDelegate從分類變爲獨立協議方法,不聽從協議就出現警告。.net

(通常上代理是weak類型,可是@property(nullable, strong) id <CAAnimationDelegate> delegate;更新以後是strong類型,暫時沒有解釋)代理

解決:利用宏進行條件編譯code

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0get

@interface LewPopupViewAnimationSpring : NSObject<LewPopupAnimation,CAAnimationDelegate>io

#else編譯

@interface LewPopupViewAnimationSpring : NSObject<LewPopupAnimation>class

#endif擴展

 

消除警告

相關文章
相關標籤/搜索