Posts

Post not yet marked as solved
1 Replies
665 Views
I am getting crashes on very simple object access after upgrading to iOS 13. See examples below. I wonder if there is some change to the language or to default settings in Xcode causing these? Or maybe there is something fundamental that I don't understand about how properties are managed? This code has been reliable for a few iOS versions until now.EXAMPLE 1: The following snipped crashes when printing _iCloudRoot: _iCloudRoot = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; if (_iCloudRoot != nil) { dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"iCloud available at: %@", _iCloudRoot); completion(TRUE); }); }Here is the property declaration:@property(nonatomic, strong) NSURL * iCloudRoot;EXAMPLE 2: The following snippet crashes when accessing calling NSURL.path on an object returned through the two member methods- (NSURL *)localRoot { if (_localRoot == nil) { NSArray * paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; _localRoot = [paths objectAtIndex:0]; } return _localRoot; } - (NSURL *) documentsFolderPath { if(_forcedDocRoot) { return _forcedDocRoot; } else if (self.iCloudAvailable && self.iCloudOn) { return [self.iCloudRoot URLByAppendingPathComponent:@"Documents" isDirectory:YES]; } else { return self.localRoot; } } - (void)loadLocal { // this crashes on [docRoot path] below... NSURL *docRoot = [self documentsFolderPath]; if(!docRoot) { NSLog(@"no doc root!"); return; } // this prevents the crash on [docRoot path] below... // NSArray * paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; // NSURL *docRoot = [paths objectAtIndex:0]; NSString* filePath = [docRoot path];Here is the property declaration:- (NSURL *) documentsFolderPath; @property(nonatomic, strong) NSURL * localRoot;Thanks!
Posted Last updated
.
Post not yet marked as solved
0 Replies
292 Views
Anyone know how to access the value of this built-in setting in iOS system preferences using objective-c? I am sure that it is there because my app has iCloud storage enabled, but I have no idea how to read it to determine whether to index the local Documents dir or the iCloud container.Thanks!
Posted Last updated
.
Post not yet marked as solved
0 Replies
366 Views
I am trying to implement the functionality that Apple suggests to move application document files to/from iCloud containers and the local docs folder when iCloud is enabled/disabled. However, NSFileManager.setUbiquitous failed with an unhelpful error 256, which says something like:Failed to move file:///Users/patrick/Documents/Test%20Case%201.fd to file:///Users/patrick/Library/Mobile%20Documents/iCloud~comPermissions on the files are typical, I can read/write the files just fine with normal user rights.The files in question are document packages with the extension .fd which have a registered UTI in my project. These document packages function properly in every other context of macOS system services (opening in finder, showing correct, icon, etc).How can I fix this problem? This is supposed to be a simple call to setUbiquitous. Maybe document packages have to be handled differently?
Posted Last updated
.
Post not yet marked as solved
1 Replies
845 Views
I am trying to limit an unpaid user to creating and saving a single document until they pay to unlock premium features. Is there any way to store a secure file or something in a registry somewhere in a manner that prevents the user from altering it?The app will run on macOS, iOS.
Posted Last updated
.
Post not yet marked as solved
0 Replies
292 Views
I have a 2016 macbook pro with high sierra and there appears no way to download an older version of macos for testing on another machine? I have to test an app that will hit an aging user base with old machines.Is this for real? Everything I can find on google is saying to go to Purchases in the app store but it won't let me download them on this mac. The only thing listed on the Apple developer downloads page are incremental upgrades.What is going on?
Posted Last updated
.
Post marked as solved
6 Replies
1.4k Views
Hello!I am trying to create a document package which stores many files in it (This will be an Electronic Health Record tool with lots of JPEGs, PDFs, etc) in a rather comples directory structure. Are there any examples for how to handle adding and removing files in NSDocument/UIDocument using NSFileWrapper? For example:- When a user adds a JPEG/PDF to the document should A) I copy the file into the package using standard file system calls, or B) read the source file as NSData, add it to my model?- If (B) above, then what might be an ideal way to create a model for a dir tree? NSMutableDictionary by { (NSString *) relativePath : (NSData *) fileData }?- When a user deletes a file from the document package, should I (C) delete the file using standard fs calls and invalidate the (NSFileWrapper*) for it, or (D) just invalidate the file wrapper and assume the file will be deleted when the document is saved?- How does saving in place or not saving in place affect the above?- Is readFromFileWrapper called when a file is added to the document package on another device?Thank you!
Posted Last updated
.
Post marked as solved
2 Replies
932 Views
I have an exported UTI which is a document package, and the file and folder structure within it are dynamic and could be changed from another device. NSMetadataQuery will not read within a document package. So my questions are:- How can I receive a list of files contained in the package along with their download status?- How can I keep the list updated when files are added to the package from other devices?Thanks!
Posted Last updated
.
Post marked as solved
1 Replies
700 Views
I am coding a custom document package type that resides on iCloud drive. The doc package will contain lots of miscellaneous files like images and pdfs. Thus, I need NSMetadataQuery to return the download status of all of the files inside a package.This was working until I checked "Document is distributed as a bundle." in the Document UTI and added an appropriate Export UTI. These settings finally got macOS to show the correct package icon in Finder and have Finder start treating the package like a file instead of a folder.Here is my code:[_query setSearchScopes:[NSArray arrayWithObject:path]]; [_query setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE '*'", NSMetadataItemFSNameKey]];I have also tried this:NSPredicate *filePredicate = [NSPredicate predicateWithFormat:@"kMDItemContentTypeTree = %@", kUTTypeData]; NSPredicate *bundlePredicate = [NSPredicate predicateWithFormat:@"kMDItemContentTypeTree = %@", kUTTypeBundle]; SPredicate *packagePredicate = [NSPredicate predicateWithFormat:@"kMDItemContentTypeTree = %@", kUTTypePackage]; NSPredicate *folderPredicate = [NSPredicate predicateWithFormat:@"kMDItemContentTypeTree = %@", kUTTypeFolder]; NSPredicate *searchPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:@[filePredicate, bundlePredicate, packagePredicate, folderPredicate]];Please help!
Posted Last updated
.
Post marked as solved
8 Replies
1.9k Views
I am trying to watch all sub-directories starting with my document package bundle on macOS, but I can only get NSMetadataQuery to report files in the immediate directory used for the scope. It does not do a recursive search.I am trying to watch for a list of files and their download status contained within my file package (NSFileWrapper *) which is stored on iCloud Drive (or anywhere the local FS), but I can only get NSMetadataQuery to return the files directly in the directory passed as a scope. It doesn't do a recursive search.Here is the only thing I could get working:_query = [[NSMetadataQuery alloc] init];NSString *root = [_DocRoot path];[_query setSearchScopes:[NSArray arrayWithObject:root]];[_query setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE '*.fd'", NSMetadataItemFSNameKey]];The following properly lists files in subdirectories on macOS and iOS when the search scope is an iCloud container, but returns nothing when run on an arbitrary folder on MacOS:[NSPredicate predicateWithFormat:@"%K LIKE '*'", NSMetadataItemFSNameKey]Does anyone know how to query for all files in a folder on the filesystem? The docs say to use "NSMetadataItemFSNameKey == *" but that throws an exception.Thank you!
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
I can't for the life of me get URLForUbiquityContainerIdentifier to work for my iCloud container on iOS. I have:Added the iCloud container to the app & provisioning profile on developer portal.Set the iCloud entitlements including containers in Xcode.Verified the team ID and entitlements in the signed app bundle:turin:pkdiagram patrick$ codesign -d --ent :- build/ios/Debug-iphoneos/Family\ Diagram.app Executable=/Users/patrick/dev/pkdiagram/build/ios/Debug-iphoneos/Family Diagram.app/Family Diagram <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>application-identifier</key> <string>8KJB799CU7.com.vedanamedia.familydiagram</string> <key>aps-environment</key> <string>development</string> <key>com.apple.developer.icloud-container-identifiers</key> <array> <string>iCloud.com.vedanamedia.familydiagram</string> <string>iCloud.com.vedanamedia.Family-Diagram</string> <string>iCloud.com.vedanamedia.PKDiagram</string> <string>iCloud.com.vedanamedia.familydiagrammac</string> <string>iCloud.com.vedanamedia.familydiagram</string> </array> <key>com.apple.developer.icloud-services</key> <array> <string>CloudDocuments</string> </array> <key>com.apple.developer.team-identifier</key> <string>8KJB799CU7</string> <key>com.apple.developer.ubiquity-container-identifiers</key> <array> <string>iCloud.com.vedanamedia.familydiagram</string> <string>iCloud.com.vedanamedia.Family-Diagram</string> <string>iCloud.com.vedanamedia.PKDiagram</string> <string>iCloud.com.vedanamedia.familydiagrammac</string> <string>iCloud.com.vedanamedia.familydiagram</string> </array> <key>com.apple.developer.ubiquity-kvstore-identifier</key> <string>8KJB799CU7.com.vedanamedia.familydiagram</string> <key>get-task-allow</key> <true/> </dict> </plist>Verified that iCloud is indeed enabled on the device:if([NSFileManager defaultManager].ubiquityIdentityToken) {Queried the doc path using teamID, containerIDNSString *teamID = @"8KJB799CU7"; NSString *bundleID = @"iCloud.com.vedanamedia.familydiagram"; NSString *containerID = [NSString stringWithFormat:@"%@.%@", teamID, bundleID]; NSURL *_iCloudRoot = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:containerID];Nothing seems to work, _iCloudRoot is always nil. Is there anything else I can check? I've been on this for hours.
Posted Last updated
.