nsfilemanager

iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

末鹿安然 提交于 2019-12-28 03:56:26
问题 Before iOS9, we had created a directory like so let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! String let logsPath = documentsPath.stringByAppendingPathComponent("logs") let errorPointer = NSErrorPointer() NSFileManager.defaultManager().createDirectoryAtPath(logsPath, withIntermediateDirectories: true, attributes: nil, error: errorPointer) But with iOS9 they removed String.stringByAppendingPathComponent. The auto convert tool replaced

iOS, Delete all data saved to device by app using NSFileManager

♀尐吖头ヾ 提交于 2019-12-26 05:39:09
问题 I want my app to delete all the information it has saved to the device, and i was told you do this using the NSFile Manager, so i was wondering what the code was to do this? 回答1: Simple , folderPath is the path of your Document Directory. NSString *folderPath; NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error]; for (NSString *strName in dirContents) { [[NSFileManager defaultManager] removeItemAtPath:[folderPath

Can i make a html file in Documents directory which accesses jquery and cordova in the app bundle?

南笙酒味 提交于 2019-12-25 17:08:24
问题 I am building a html file which is stored in [[PROJ UserDirectory] stringByAppendingPathComponent:@"tmp_Form_File.html"] and inside of the file "tmp_FOrm_File.html" it is being dynamically built. Body shows up correctly but the JS will not execute. I was trying to do: NSString * cordova_path = [[NSBundle mainBundle] oathForResource:@"cordova-2.2.0" ofType:@"js" inDirectory:@"html"] NSString = [[@"<script type=\"text/javascript\" src=\"" stringByAppendingString:cordova_path]

Can i make a html file in Documents directory which accesses jquery and cordova in the app bundle?

孤者浪人 提交于 2019-12-25 17:07:29
问题 I am building a html file which is stored in [[PROJ UserDirectory] stringByAppendingPathComponent:@"tmp_Form_File.html"] and inside of the file "tmp_FOrm_File.html" it is being dynamically built. Body shows up correctly but the JS will not execute. I was trying to do: NSString * cordova_path = [[NSBundle mainBundle] oathForResource:@"cordova-2.2.0" ofType:@"js" inDirectory:@"html"] NSString = [[@"<script type=\"text/javascript\" src=\"" stringByAppendingString:cordova_path]

unable to write to a file in AplicationSupport directory

半腔热情 提交于 2019-12-25 12:58:25
问题 I am trying to store some values in a plist in the Application support directory of my iOS app. But the write always fails. I used boiler plate code from iOS documentation. In the code below I always hit an error while doing writeToURL:atomically. I.E I always get a "Failed to write to plist" in the log and the file is never created. The URL appears to be created correctly. This is what I see in the URL print below. URL to store plist is file:///var/mobile/Containers/Data/Application/9E26C447

Why does NSFileManager return TRUE on fileExistsAtPath when there is no such file?

最后都变了- 提交于 2019-12-25 07:58:52
问题 NSFilemanager is returning true for the following, when there should not be any such file there yet. What is happening? if([myManager fileExistsAtPath:[[self documentsDirectory] stringByAppendingPathComponent:@"Music/songlist.txt"]]){ NSLog(@"file is there"); } 回答1: The documentation for NSFileManager seems to recommend not checking to see if files exist, and instead just trying to read the file and handle any errors gracefully (e.g. file not found error). What you are describing doesn't

How to retrieve nested file with FileManager?

╄→尐↘猪︶ㄣ 提交于 2019-12-25 07:49:06
问题 In my app, I create this folder structure as soon as the app launches for the first time: I read here Can I save the keep the absolute path of a file in database? - that I should not store the absolute path to a directory or file. Therefore I am having trouble getting reference to the last file shown in the picture above called I-Want-This-File-Path . I could get access up to the Feed folder in the picture above like so: extension FileManager { /// APPLICATION SUPPORT DIRECTORY static func

NSFileManager Cant create file

一曲冷凌霜 提交于 2019-12-25 07:47:37
问题 I have this code. This code won't create a file in the Document directory and i have no idea why. Can anyone see what I'm missing. "data" dictionary has what i need in it but when it comes to writeToFile: it's not happening because there is no file created. The same code work's in other apps i have, I'm surely missing something. - (void)addBookmark{ NSFileManager *fileManager = [NSFileManager defaultManager]; if (![fileManager fileExistsAtPath: [self filePathOfBookmarks]]) { [self

NSFileSystemFileNumber is changed after file is edited/updated in objective c

廉价感情. 提交于 2019-12-24 21:45:51
问题 I am working on File Management System exactly like Dropbox in Cocoa . My problem is when i edit any text file at that time NSFileSystemFileNumber is changed. I want an unique NSFileSystemFileNumber even if that edited file is moved from the particular folder. In short, I just want to know how to fetch that moved file's old or original path from the database. Any alternate way to solve out this problem? Thanks in Adv..!! 回答1: It depends on how the editor save functionality is implemented.

Filter NSFileManger contents for a list of file 'patterns' using NSPredicate

一世执手 提交于 2019-12-24 21:28:29
问题 I've an array of strings to be used as a 'filter': @[@"*.png", @".DS_Store", @"Foobar", @".jpg"] How do I use above pattern to filter out all the contents of a folder using NSPredicate? This is what I've got so far: NSArray *contents = [fileManager contentsOfDirectoryAtPath:fullPath error:NULL]; NSArray *filter = @[@"*.png", @".DS_Store", @"Foobar", @".jpg"]; NSArray *contents = [contents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"((pathExtension IN[cd] %@) OR