ios - Deprecation and other attributes of methods in Swift, how? -


in objective-c can this

- (id)init __attribute__((unavailable("init unavailable, use initwithframe"))); 

to warn users should not use method initialization of class , can add other __attribute deprecate method

+(void)sharewithparams:(nsdictionary *)params __attribute((deprecated("use sharewithpars: instead")));  

is possible in swift?

swift has available attribute can use this. it's available arguments include

  • introduced
  • deprecated
  • obsoleted
  • message
  • renamed.

or example gave:

@available(*, unavailable, message="init unavailable, use initwithframe") init() {  }  @available(*, deprecated, message="use sharewithpars: instead") class func sharewithparams(params: nsdictionary) {  } 

for more information on these attributes, check out attributes section in the swift programming language. (currently page 627)


Comments