Re: NSFileManager - Incompatible persistent store
Hey Sean, Thank you! Though this didn't quite work. I'm getting an error response in the code telling me No visible @interface for 'NSFileManger' declares the selector 'createDirectoryAtURL:attributes'. Included in this message is the code im playing with, https://dl.dropbox.com/u/3783094/BlogDemoAppDelegate.m https://dl.dropbox.com/u/3783094/BlogDemoAppDelegate.m On Thu, Nov 22, 2012 at 10:58 AM, Sean McBride s...@rogue-research.comwrote: On Wed, 21 Nov 2012 18:17:26 -0500, Tom Miller said: Sorry my bad! The warning states 'createDirectoryAtPath:attributes:' is depreciated. I was able to get rid of that window warning once the app launched, miss spelled something in my code. Though I'm still unable to save the imputed text to the XML. I can provide the entire set of code if needed to. Tom, Most path-based and non-NSError-returning file APIs are deprecated, and you should use URL+NSError methods instead: createDirectoryAtURL:withIntermediateDirectories:attributes:error: Also, using fileExistsAtPath: is rarely the right thing due to race conditions: it's possible the file didn't exist when you checked, then gets created by a different process before you get to create it. Instead, just try to create it, and be ready for a returned error like 'already exists'. See: https://developer.apple.com/library/mac/#documentation/security/conceptual/SecureCodingGuide/Articles/RaceConditions.html Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada -- - Tom Miller t...@pxlc.me pxlc.me ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On 26/11/2012, at 9:44 AM, Tom Miller t...@pxlc.me wrote: Thank you! Though this didn't quite work. I'm getting an error response in the code telling me No visible @interface for 'NSFileManger' declares the selector 'createDirectoryAtURL:attributes'. Included in this message is the code im playing with, So, have you actually tried Sean's suggestion of using -createDirectoryAtURL:withIntermediateDirectories:attributes:error: ? You should also make your method -applicationSupportFolder return a NSURL not a path string. There's no good reason for new code to be using a deprecated method, and sticking with paths instead of URLs is not a good long-term strategy. I've just spent a lot of time moving a bunch of older code from path strings to URLs and it's a lot of work, so unless you have to support a much older version of OS X, use NSURL now. Also, as suggested, checking for the existence of the folder before trying to create it is considered a bad design pattern these days - the method will create the directory IF NECESSARY, and if not (i.e. it exists already) will gracefully return without error. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On Wed, 21 Nov 2012 18:17:26 -0500, Tom Miller said: Sorry my bad! The warning states 'createDirectoryAtPath:attributes:' is depreciated. I was able to get rid of that window warning once the app launched, miss spelled something in my code. Though I'm still unable to save the imputed text to the XML. I can provide the entire set of code if needed to. Tom, Most path-based and non-NSError-returning file APIs are deprecated, and you should use URL+NSError methods instead: createDirectoryAtURL:withIntermediateDirectories:attributes:error: Also, using fileExistsAtPath: is rarely the right thing due to race conditions: it's possible the file didn't exist when you checked, then gets created by a different process before you get to create it. Instead, just try to create it, and be ready for a returned error like 'already exists'. See: https://developer.apple.com/library/mac/#documentation/security/conceptual/SecureCodingGuide/Articles/RaceConditions.html Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On 23/11/2012, at 2:58 AM, Sean McBride s...@rogue-research.com wrote: Most path-based and non-NSError-returning file APIs are deprecated Is that documented anywhere? All I can see is this in the NSFileManager reference: The NSFileManager class supports both the NSURL and NSString classes as ways to specify the location of a file or directory. The use of the NSURL class is generally preferred for specifying file-system items because they can convert path information to a more efficient representation internally. That strikes me as a long way from deprecation. -- Shane Stanley sstan...@myriad-com.com.au 'AppleScriptObjC Explored' www.macosxautomation.com/applescript/apps/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On Fri, 23 Nov 2012 09:14:51 +1100, Shane Stanley said: Most path-based and non-NSError-returning file APIs are deprecated Is that documented anywhere? Not sure if it's called out in black and white, but you just have to browse the headers to see that all the newer file-related APIs use NSURL and NSError, and all the old ones use NSString paths and/or have no NSError return value. Just consider the starting point of file access, NSOpenPanel: the 'filenames' method is replaced by 'URLs'. The rest kinda follows. Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSFileManager - Incompatible persistent store
I'm working with some code that accesses a data model in Xcode. String data is written to an xml file in the app (Mac) and displayed in a list. The inputted text is saved as body text and title. The app compiles but I receive a warning upon launch, *The managed object model version used to open the persistent store is incompatible with the one that is used to create the persistent store.* The app launches and I'm able to save (kinda) the inputted text, add title, and view from a list of created titles/body text. The only problem is the inputted text is not saved and reopened once the app launches again. I'm assuming this has to be because of the persistent store. I receive a warning in Xcode about this line of code dealing with the file manager, fileManager = [NSFileManager defaultManager]; applicationSupportFolder = [self applicationSupportFolder]; if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) { [fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil]; } -- - Tom Miller t...@pxlc.me pxlc.me ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On 21 Nov 2012, at 21:16, Tom Miller t...@pxlc.me wrote: I receive a warning in Xcode about this line of code dealing with the file manager, fileManager = [NSFileManager defaultManager]; applicationSupportFolder = [self applicationSupportFolder]; if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) { [fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil]; } Care to tell us what the warning actually is? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
On Wednesday, November 21, 2012, Tom Miller wrote: Sorry my bad! The warning states 'createDirectoryAtPath:attributes:' is depreciated. I was able to get rid of that window warning once the app launched, miss spelled something in my code. Though I'm still unable to save the imputed text to the XML. I can provide the entire set of code if needed to. On Wednesday, November 21, 2012, Mike Abdullah wrote: On 21 Nov 2012, at 21:16, Tom Miller t...@pxlc.me wrote: I receive a warning in Xcode about this line of code dealing with the file manager, fileManager = [NSFileManager defaultManager]; applicationSupportFolder = [self applicationSupportFolder]; if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) { [fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil]; } Care to tell us what the warning actually is? -- - Tom Miller t...@pxlc.me javascript:_e({}, 'cvml', 't...@pxlc.me'); pxlc.me -- - Tom Miller t...@pxlc.me pxlc.me ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFileManager - Incompatible persistent store
Sorry my bad! The warning states 'createDirectoryAtPath:attributes:' is depreciated. I was able to get rid of that window warning once the app launched, miss spelled something in my code. Though I'm still unable to save the imputed text to the XML. I can provide the entire set of code if needed to. On Wednesday, November 21, 2012, Tom Miller wrote: Sorry my bad! The warning states 'createDirectoryAtPath:attributes:' is depreciated. I was able to get rid of that window warning once the app launched, miss spelled something in my code. Though I'm still unable to save the imputed text to the XML. I can provide the entire set of code if needed to. On Wednesday, November 21, 2012, Mike Abdullah wrote: On 21 Nov 2012, at 21:16, Tom Miller t...@pxlc.me wrote: I receive a warning in Xcode about this line of code dealing with the file manager, fileManager = [NSFileManager defaultManager]; applicationSupportFolder = [self applicationSupportFolder]; if ( ![fileManager fileExistsAtPath:applicationSupportFolder isDirectory:NULL] ) { [fileManager createDirectoryAtPath:applicationSupportFolder attributes:nil]; } Care to tell us what the warning actually is? -- - Tom Miller t...@pxlc.me javascript:_e({}, 'cvml', 't...@pxlc.me'); pxlc.me -- - Tom Miller t...@pxlc.me pxlc.me ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com