开发者

How do I find solutions for deprecated code?

开发者 https://www.devze.com 2023-03-08 08:06 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消