Become a MacRumors Supporter for $25/year with no ads, private forums, and more!
  • Did you order new AirTags? We've opened a dedicated AirTags forum.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
I've finally had to "upgrade" to OS X 10.7 (which I REALLY HATE). Some of the object methods in my code have been deprecated. One that is used in my code to save data in files is:

[NSSavePanel* filename];

According to the Documentation you should use [NSSavePanel URL] instead. A lot of objects can use a URL instead of an NSString - for example [NSImage writeToURL: atomically:];

One method that still needs an NSString is the NSKeyedArchiver method
archiveRootObject:toFile: - file is an NSString.

Theoretically one could get the NSSavePanel's URL using [NSSavePanel URL] and then get an NSString using some NSString method like

+ stringWithContentsOfURL:usedEncoding:error:
– initWithContentsOfURL:usedEncoding:error:

For some reason these return a nil NSString and error looks like an NSCocoaDomainError, code 260.

Perhaps one of you could suggest how I might continue to use archiveRootObject:toFile: without relying on the deprecated method [NSSavePanel filename].


Nov 25, 2005
It might not be a file. The URL might point to some server in the cloud, or it might point to some server in the cloud when the user runs your app in 10.8 or 10.9. There's probably a reason why it's deprecated.


macrumors 68020
Aug 17, 2009
I would suggest you use -archivedDataWithRootObject: to get a NSData object, then use one of the NSData methods that writes to a URL. This URL scheme was on the horizon with Leopard, steadily approaching like some kind of large feline, you need to get used to it.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.