A declaration cannot be both 'final' and 'dynamic' error in Swift 1.2 -


the declaration of value below

import foundation  class aaa: nsobject {     func test2() {         self.dynamictype     } } extension aaa {     static let value    =   111 } 

causes following compilation error

a declaration cannot both 'final' , 'dynamic' 

why happen, , how can deal this?

i using swift 1.2 (the version shipped within xcode 6.3.1 6d1002)

this issue arises because swift trying generate dynamic accessor static property obj-c compatibility, since class inherits nsobject.

if project in swift only, rather using var accessor can avoid issue via @nonobjc attribute in swift 2.0:

import foundation  class aaa: nsobject {} extension aaa {     @nonobjc static let value = 111 } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -