Brian
Brian

Reputation: 101

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.

Upvotes: 4

Views: 652

Answers (3)

Abizern
Abizern

Reputation: 150635

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.

Upvotes: 5

Alex Wayne
Alex Wayne

Reputation: 187114

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.

Upvotes: 0

omz
omz

Reputation: 53551

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.)

Upvotes: 1

Related Questions