Check if method is deprecated - objective-c

Is there any possibility to programmatically detect if a particular method is deprecated in the current version of system? Thanks

No, there is no any way to programmatically detect if a particular method is deprecated in the current version of system. The only thing you can get to know through warning message that your method is deprecated.

warnings are based on your deployment target.
set the Deployment Target to the latest version.
Do a build from the Product menu, see all the warnings.

You (and others getting here) may be trying to ask a slightly different question - how can you check to see if a deprecated method (aMethod:) of a non deprecated class (aClass) is still available at runtime? You can do that with:
if([aClass instancesRespondToSelector:#selector(aMethod:)]){
// it's still available for use
}

Related

SonarQube: How to suppress a warning in Kotlin code

I'm using SQ 7.3-alpha1 with sonar-kotlin-plugin-1.0.1.965.jar. However, I cannot deactivate a special warning inside my Kotlin code for repositories in Spring Data where I need an "_" in a method name.
I tried both //NOSONAR and #Suppress("kotlin:S100") and #SuppressWarnings("kotlin:S100"). Any hint is appreciated.
You're not able to deactivate that issue because none of the mechanisms you're trying to use have been implemented for Kotlin.
Instead, you'll have to do this from the UI side.
Great news, https://jira.sonarsource.com/browse/SONARSLANG-373 is fixed in version 1.6 of Sonarslang. So an update to that version might improve the situation. I’ve not tested it yet, hence the cautious wording.

How can I support older xaml version and still use new controls from the newer version.

I got a warning while building my xaml project:
The type ‘SvgImageSource’ is not available in the target platform
minimum version (10.0.14393.0)
I understand that I'm getting this because 14393 does not have an SvgImageSource control.
I still want to use the control and I also want to support 14393. Is that possible? Is there a way for me to create an alternative control for the older version?
This will be possible starting from the Creator's Update (15063) with Conditional XAML.
Conditional XAML provides a way to use the ApiInformation.IsApiContractPresent method in XAML markup. This lets you set properties and instantiate objects in markup based on the presence of an API without needing to use code behind. It selectively parses elements or attributes to determine whether they will be available at runtime.
I suppose you're using the control for SVGs. If you really need to run on older Windows 10 versions, have a look at this post from Igor Ralic on the Mntone.SvgForXAML library. That will be a lot easier than trying to create the control yourself.
Extra note: if you're still working on the app and are not releasing in the next few weeks, then it might be an option to skip straight to the Creator's Update. Already over 65% of the devices are on 15063 or higher in August and it's raising every week.

Is the method removeAndReturnError: not necessary?

I've just read the documentation about conflict resolution with UIDocuments in the iCloud:
Resolving Document Version Conflicts
In the last point of the chapter "How to Tell iOS That a Document Version Conflict Is Resolved" is written:
Remove the resolved versions of the document.
For any versions you no longer need, call the removeAndReturnError: method of NSFileVersion to reclaim the storage for the file. Document revisions remain on the server until you delete them.
But in the code sample "Listing 6-3" there is no removeAndReturnError: method called.
Is this method not necessary or where should I call it?
Thanks for any help
Linard

How do I find solutions for deprecated code?

I'm new to Mac programming. When I open sample projects, I often get 'deprecated' code warnings during a build. I'd like to fix these and get a clean build using XCode 4.
When Apple deprecates something, how do I find out why it was deprecated?
More importantly, how do I find out what is the 'new' correct way to implement the deprecated task?
For example, I'm seeing deprecation warnings for: QTMovieSizeDidChangeNotification, writeWithBackupToFile, documentForFileName, shouldCreateUI, setShowPanels, QTMovieCurrentSizeAttribute, and many others.
Look up the method in the documentation - they show the deprecated methods and tell you what the preferred methods are.
For example writeWithBackupToFile is clearly marked as deprecated and shows that writeSafelyToURL:ofType:forSaveOperation:error: should be used instead.
Same with shouldCreateUI which shows that either openUntitledDocumentAndDisplay:error: or openDocumentWithContentsOfURL:display:error: should be used instead.
Also, read the other methods in the documentation - you'll find things that do what you need. For example you list QTMovieSizeDidChangeNotification as being deprecated (in QuickTime 7.6.3). Right above it in the documentation you can see QTMovieNaturalSizeDidChangeNotification which has been available since QuickTime 7.6.3). Use that instead.
Look for the deprecated things in the documentation. Usually, there's a note that suggests what to use instead.
For example, the documentation for writeWithBackupToFile:ofType:saveOperation: says:
This method is called by action methods to save document contents to a file. (Deprecated in Mac OS X v10.4. Use writeSafelyToURL:ofType:forSaveOperation:error: instead.)
Search the documentation for that method/function/constant. It should list there what to use instead, or at least bring up a class that obviously has other methods that do something similar.

Where to find updates for deprecated functions?

Xcode4 will tell you if a function is deprecated but does not provide any info on what to use as the latest update for that function. What is the best way to find out the updated version of any deprecated function?
I always search the documentation with the function name and get the new version of the old methods. It works all the time.
There is a drop down(Doc Set) to select the libraries you want to search, in the Documentation window