I am refactoring a large iOS Swift
project gradually. Some function have to be renamed and I cannot rename directly because many other modules directly calling it. Instead, for the first phase release, I want to let the caller of a function know that please use this func instead of this func. Let me explain with an example,
func length() - > Int {
//..... some logic
}
Expecting to refactor it in next version to,
func count() - > Int {
//..... same logic
}
For the 1st phase I want to keep both length()
and count()
but let other developers be warned not to use existing one, i.e. length(). So I tried with,
func length() - > Int {
#warning("Please use count() instead")
//..... some logic
}
But the warning is thrown in the line but not to the caller. So, what are the best way to let caller be informed about wrong call?
Note: The example here is just a simplest form to understand the problem. Actual implementation is much broader in scope and module size.
@available(*, renamed: "count()")
option as well, because that offers an inline rename feature in Xcode. – Dominion