To be clear, the folder is the 'documents' folder from my own app's container:/Users/<username>/Library/Containers/com.myapp.macapp/Data/DocumentsIs this folder also protected now? I saw the linked video, but it wasn't clear what was new in this regard, or what I would need to do to fix this. Again, I'm using NSMetadataQuery to monitor this folder for changes. When building my app in Xcode, in 'Signing & Capabilities', I already have the "User Selected Files" permission selected with Read/Write, though not the others (Downloads, Pictures, Music, Movies).
Post
Replies
Boosts
Views
Activity
I've also tried giving my app "Full Disk Access" permissions, from System Preferences, but doesn't seem to help.
Figured out a work-around .... updating the map's span (i.e. zoom level) causes the tiles to reload, and the updated mapType now shows correctly. I wish that wasn't necessary, but at least it works now.
Thanks for the response. I want to figure out a way where I can process a autorenewing subscription in the background, since some of my features aren't in the app itself but work though Shortcuts and Share Extensions. The user can go days without opening my app, so the subscription might have expired in the meantime. I figure that with BGAppRefreshTaskRequest there is some possibility of being able to refresh the receipt. From what little I've read, it seems that for production accounts, the receipt is always present (or at least if one transaction has been processed), so SKReceiptRefreshRequest wouldn't need to prompt the user to login to their App Store account. Is that information incorrect? Are there particular circumstances when a user is prompted to login to the App Store, or is it random / unknowable?
Thanks for the reply. I'm confused about how to setup the UIDiffableDataSource object. I can setup the cellProvide first:
UITableViewDiffableDataSourceCellProvider cellProvider = ^UITableViewCell*(UITableView * tableView, NSIndexPath *indexPath, NSDictionary *itemDictionary) {
CJSiriShortcutsSettingsTableViewCell *cell = (CJSiriShortcutsSettingsTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"ShortcutsCellIdentifier" forIndexPath:indexPath];
/// ... setup the cell here
}
Then I want to setup the datasource object, and I'm wondering if this is the right way to do it:
UITableViewDiffableDataSource <SiriShortcutsSection, NSDictionary *> *dataSource = [[UITableViewDiffableDataSource alloc] initWithTableView:self.tableView cellProvider:cellProvider];
self.tableView.dataSource = dataSource;
The 'SiriShortcutsSection' is a enum:
typedef enum : NSUInteger {
SiriShortcutsSectionExisting,
SiriShortcutsSectionAdd
} SiriShortcutsSection;
The compiler is giving an error:
Type argument 'SiriShortcutsSection' is neither an Objective-C object nor a block type
How do I define that 'section' object? And can I pass in an 'NSDictionary' for the item, or do I have to implement isEqual and hash on that as well? Should it be a custom object with an NSDictionary inside it?
Thanks for the help.
So I created a new class for that 'section' object and it works (compiles, at least):
@interface CJSiriShortcutsSectionIdentifier : NSObject
@property (nonatomic) SiriShortcutsSection sectionType;
@end
When I use it in a snapshot, and 'apply', it produces an empty tableview:
NSDiffableDataSourceSnapshot<CJSiriShortcutsSectionIdentifier *, NSDictionary *> *snapshot = [[NSDiffableDataSourceSnapshot alloc] init];
if (self.existingShortcutsSortedArray.count) {
CJSiriShortcutsSectionIdentifier *sectionExisting = [[CJSiriShortcutsSectionIdentifier alloc] initWithSection: SiriShortcutsSectionExisting];
[snapshot appendSectionsWithIdentifiers: @[sectionExisting]];
[snapshot appendItemsWithIdentifiers:self.existingShortcutsSortedArray intoSectionWithIdentifier:sectionExisting];
}
UITableViewDiffableDataSource <CJSiriShortcutsSectionIdentifier *, NSDictionary *> *dataSource = self.tableView.dataSource;
[dataSource applySnapshot:snapshot animatingDifferences:YES];
I know that self.existingShortcutsSortedArray has an array of NSDictionary objects.
Is there something I'm missing? Do I need to implement isEqual on the CJSiriShortcutsSectionIdentifier class? Or something else as well?
So the problem was something else. In viewDidLoad, I setup the datasource and assign it to the tableView, and create an empty initial snapshot, since the data hasn't loaded yet :
UITableViewDiffableDataSource <CJSiriShortcutsSectionIdentifier *, NSDictionary *> *dataSource = [[UITableViewDiffableDataSource alloc] initWithTableView:self.tableView cellProvider:cellProvider];
self.tableView.dataSource = dataSource;
NSDiffableDataSourceSnapshot<CJSiriShortcutsSectionIdentifier *, NSDictionary *> *snapshot = [[NSDiffableDataSourceSnapshot alloc] init];
[dataSource applySnapshot:snapshot animatingDifferences:NO];
Then in viewWillAppear, I make an async call to get the latest data, and then try to apply the snapshot there, using the tableview's datasource object, but that seemed to be 'nil' at that point for some reason:
/*... after viewWillAppear loads data with an async call, call this on the dispatch_get_main_queue */
NSDiffableDataSourceSnapshot<CJSiriShortcutsSectionIdentifier *, NSDictionary *> *snapshot = [[NSDiffableDataSourceSnapshot alloc] init];
if (self.existingShortcutsSortedArray.count) {
CJSiriShortcutsSectionIdentifier *sectionExisting = [[CJSiriShortcutsSectionIdentifier alloc] initWithSection: SiriShortcutsSectionExisting];
[snapshot appendSectionsWithIdentifiers: @[sectionExisting]];
[snapshot appendItemsWithIdentifiers:self.existingShortcutsSortedArray intoSectionWithIdentifier:sectionExisting];
}
UITableViewDiffableDataSource <CJSiriShortcutsSectionIdentifier *, NSDictionary *> *dataSource = self.tableView.dataSource; /* THIS IS NIL*/
[dataSource applySnapshot:snapshot animatingDifferences:YES];
Turns out, the problem was that the UITableViewDiffableDataSource needed to be strongly retained by the view controller. Now it works fine, and loads the data into the tableview!
Thanks for the help.
The only question left is this: do we need to implement the hash and isEqual: methods as well in the Objective-c class? Or does that already happen with Objective-C?
Thanks for the reply; that's really helpful. I have it working now. To resolve my confusion, I created separate classes for both the SectionIdentifier and ItemIdentifier, and for both of them, implemented isEqual: and hash. For the ItemIdentifier, in the isEqual: and hash implementations, I had to include *both* the uniqueID and any other property that was possible to update. That way, when those properties change, they would reload that UITableViewCell automatically as well.
Did anyone get this to work? I'm not sure how to load the managedObjectContext into the SwiftUI widget view. Usually we dive back to the AppDelegate to get that, but I'm guessing that this isn't possible from the widget. Can someone clarify?
Adding Radar to help track this: FB7859251
bump* Can someone please help? I'm stuck because my project doesn't compile with Xcode12. It was working with Beta1.
No; I have removed PhoneNumberKit from my iOS14 branch for now, so I can work on other stuff, but will need to put it back eventually. Hopefully someone has an idea of what to do in this case .... maybe build from source, which I haven't tried.
Same here. If there is a safe solution to this, would love to hear about it.
Turns out, due to some sizing issues, I was already calling collectionView.reloadData() inside viewWillLayoutSubviews() ... when I remove that line, the selection issue goes away.