Post not yet marked as solved
So in the CloudKit dashboard I have the "recordName" field marked as queryable.
I notice that this query fails with an error:
	 CKQuery *query = [[CKQuery alloc]initWithRecordType:recordType
predicate:[NSPredicate predicateWithFormat:@"recordName == %@",recordName]];
I get an error. It seems I have to put the recordName in a CKRecordID, and then query for recordID to essentially query by the unique recordName.
Is querying by recordName directly not supported or am I doing something wrong?
Post not yet marked as solved
When I drag to make a constraint from a view to its superview in Interface builder, I no longer see the "Equal widths" in the list of constraints to choose.If I click the little "Add New Constraint" button, I do have the ability to make a "width" constraint and specify a static value, but I don't see how to make equal width relative to the superview?
Post not yet marked as solved
So, when copying a file or directory (particularly to an external drive) i've noticed there is a huge difference in performance between a sandboxed and non-sandboxed app.When copying a directory and the app isn't sandboxed, the copy finishes in reasonably fast (like a minute..didn't time it though). When sandboxed, copying is still going on...very slowly, it's been like 20 minutes. Still isn't finished. For what it's worth, when using NSFileManager API to copy I notice big performance hit too when the app is sandboxed (not sure if NSFileManager is just wrapping copyfile anyway). Anyone know why and if there is a workaround?
Post not yet marked as solved
So I added multiple window support for iPad in an app.
Now I understand if there are 'windows' open killing the window in the app switcher won't cause the app to terminate.
When I have two windows open in the same "scene" in split view...and I kill that scene in the app switcher, Xcode immediately terminates my debug session as if the app has been killed.
However, when I hit run to try to get a "fresh" run of the app, my split view windows are restored (I'm not using a state restoration activity)..and application:didFinishLaunchingWithOptions: is *not* called.
So even though all windows are closed (users sometimes kill apps by removing them in the app switcher manually) my app is skipping the -application:didFinishLaunchingWithOptions method in the app lifecycle.
Are users no longer able to really "quit" apps in the App Switcher when an iPad app supports multiple windows? How can a user terminate an app?
Post not yet marked as solved
Loading a NSViewController xib from within another xib (by dragging a NSViewCOntroller object that references another xib) I'm getting incorrect results. I'm *not* using storyboards.
The view controller's view has a fixed width and is not resizable. It's set to 513.
When its unarchived from Interface Builder, the view is clipping.
So I logged out the frame in viewDidLoad, and the width of the view is unexpectedly 460.
Also I notice I have a window with a width set in IB to 513, but at runtime it's 514.
Everything in this xib is static and it has been around for years. Never used autolayout in this xib. But my only guess is autoresizing/translate masks into constraints behavior is now doing something different?
I saw there was a session titled "Advances in the Objective-C runtime" scheduled for WWDC but I can no longer find it in the Developer app. Was it scrubbed?
Post not yet marked as solved
Using the COPYFILE_EXCL flag with the copyfile function works as expected when copying files (the copy fails if a file at the destination path already exists).But when copying a directory, if you specify this flag and the destination already exists copyfile will just copy the directory inside of the already existing directory, instead of failing with an error. Does anyone know why? It seems kind of peculiar to copy a directory to a location not specified by the caller?As far as I can tell the only way to get the behavior to work the way I'd expect is to look before you leap? So I'd have to do:if (destinationURLIsDirectory && [destinationURL checkResourceIsReachableAndReturnError:nil])
{
NSLog(@"fail...destination already exists..don't start copyfile");
return;
}
Can someone explain the distinction between these two attributes: NSURLVolumeIsLocalKey and NSURLVolumeIsInternalKey?The documentation for NSURLVolumeIsLocalKey:Key for determining whether the volume is stored on a local device, returned as a Boolean NSNumber object (read-only).And the documentation for NSURLVolumeIsInternalKey:Key for determining whether the volume is connected to an internal bus, returned as a Boolean NSNumber object, or nil if it cannot be determined (read-only).So, when I look at the values of these attributes for a volume mount on the local network both are NO as expected.When I connect a usb stick to my Macbook pro via a dongle (since i only have USB-c ports) I get YES for local, but NO for internal when I was actually expecting the values to be the other way around. Can someone clarify the distinction between these two attributes?Thanks
Post not yet marked as solved
So I noticed when sending data using MultipeerConnectivity I'm not sure exactly how I'm supposed to distinguish between an error or a declined invitation. For example I have Device Sender & Device Receiver.1) Device Sender sends device Receiveran invitation using MCNearbyServiceBrowser's method -invitePeer:toSession:withContext:timeout:2) Device Sender hasthe delegate set on the session used to send the invitation.3) The delegate for the MCSession invitation waits for -session:peer:didChangeState: before sending the real meat.-(void)session:(MCSession*)session peer:(MCPeerID*)peerID didChangeState:(MCSessionState)state
{
if (state == MCSessionStateConnecting)
{
}
else if (state == MCSessionStateNotConnected)
{
if (self.waitingOnReceiverToAcceptInvite)
{
NSLog(@"uh o, never got started abort...invitation was declined?");
[session disconnect];
}
else
{
//Not connected. Maybe we finished all our work already, maybe not...
//handle error in the completion handler of -sendResourceAtURL:withName:toPeer:withCompletionHandler:
//if we have one
}
}
else if (state == MCSessionStateConnected)
{
if (self.waitingOnReceiverToAcceptInvite)
{
self.waitingOnReceiverToAcceptInvite = NO;
[self beingSendingStuffToReciever];
}
}
}So... the -beingSendingStuffToReciever method sends a resource using the session's sendResourceAtURL:withName:toPeer:withCompletionHandler:So during testing, if the Receiver declines the invitation the Sender's session gets -session:peer:didChangeState: with a not connected state. If the waitingOnReceiverToAcceptInvite property is YES, I bail on the session and assume the invitation was declined. Why? Because I don't see any other way to detect if the Sender declined the invitation. But, during testing, I noticed that other reasons (like errors which seem to be abstracted away and inaccessible from the MultipeerConnectivity API) can cause the session delegate to get a -session:peer:didChangeState: message with a MCSessionStateNotConnected state while my waitingOnReceiverToAcceptInvite is YES.So the peer is not connected to the session and I don't see a way to determine why. Was there some sort of network error and can I retry or did the Receiver just decline the invitation? How am I supposed to know? Is there some other API in this framework that I'm missing?Thanks a lot
In previous versions of Xcode you could preview UI in Interface Builder in another localization by doing this:1) Open the xib.2) Open the Assistant Editor and select Preview. Then in the bottom right corner it showed a language, which you could change.In Xcode 11 is there a new way to do this? Or do I have to change my default language in System preferences and run the app?
Post not yet marked as solved
Was wondering if there is a way to sniff the users trackpad settings for 3 finger dragging. The reason why I want to do this because I noticed a situation where NSScrollview sometimes scrolls during 3 finger dragging and swallows the 3 finger drag event.To workaround this, I could subclass NSScrollview and block scrolling during 3 finger drag. But when 3 finger dragging preference is not set, there's really no point in blocking scrolling because scrolling with 3 fingers on the trackpad ought to be permitted when the user isn't using that gesture for dragging. But as far as I can tell, there's no way to tell if the user has the preference on or off.
My local database has a table that stores database changes. This is used to track changes made when the current device is offline. Here's my question, what's the recommended way to detect whether or not a delete change should be merged?So say I have a record titled Note. Device 1 is offline and deletes Note. Now Device 2 is online and edits Note after Device 2 deletes it.Now Device 1 comes back online and sends the delete to Cloudkit. Ideally, I'd like to get a CKErrorServerRecordChanged error for the delete since Device 2 got an edit to the server and Device 1 is deleting data it never had. If this is the case, I can inspect some other fields on my record and decide how I want to merge (I could use the last write wins. Did the user edit the record on Device 2 after it was deleted on device 1? If so, I can make Device 2 the winner OR I can ask the user what he wants).BUT you don't specify a CKRecord for deletes. Instead you give a CKModifyRecordsOperation a CKRecordID to delete. And CKRecordIDs don't include a change tag, so I assume the delete will go through even if the save policy is set to CKRecordSaveIfServerRecordUnchanged and the record to be deleted by the current device was changed in between?
Post not yet marked as solved
I see in CKError.h there is an error: CKErrorConstraintViolation.Is there a way to specify a unique constraint for a column in a CloudKit record?The only part of a CloudKit record that enforces uniqueness as far as I can is recordName (which is specified via CKRecordID). This has limitations though. One being recordName must be 255 characters or less. For the most part, using user input on some field which must be unique in a user created record can be used as a record name to ensure uniqueness. In most cases, this will be under 255 characters but not always though.During testing, I'm just using a hash string for the record name, which will fit in 255 characters:NSString *someStringThatRepresentsUniqueValue = //...
NSString *ckRecordName = [NSString stringWithFormat:@"%lu",someStringThatRepresentsUniqueValue.hash];But my concern with this is if that the implementation of hash could change in an OS update. Yea, I could hash myself, but my question still stands: is there no way to just make a unique constraint in the database for a custom field?
Post not yet marked as solved
When I run my app and do a CKModifyRecordsOperation to save a record that already exists on the server (with no changetag) to test merging I do indeed get a CKErrorServerRecordChanged.There is no values in the user info dictionary of this error for CKRecordChangedErrorClientRecordKey or CKRecordChangedErrorServerRecordKey. Instead there is an NSUnderlying error which prints out:server message = "SaveSemantics is failIfExists, existing record has chaining, new record does not"So, I was able to track down the cause to hit this condition. The server record is a parent to an existing record. I'm not sure why being the parent would prevent the normal merging flow. In order to "merge" with the server record, I have to create a query operation and pull it down, instead of just getting the record from the user info.I was just using parents for potentially future use with sharing (currently not used in my app). But I think i'll just remove parent references because they seem to cause too many problems.FB7440624
Post not yet marked as solved
So, using the new api to do the "peek/pop" like stuff on iOS 13:-(void)webView:(WKWebView*)webView
contextMenuConfigurationForElement:(WKContextMenuElementInfo*)elementInfo
completionHandler:(void (^)(UIContextMenuConfiguration * _Nullable configuration))completionHandler
{
NSURL *theURL = elementInfo.linkURL;
if (theURL != nil)
{
UIContextMenuConfiguration *config = [UIContextMenuConfiguration configurationWithIdentifier:nil
previewProvider:^UIViewController * _Nullable
{
SomeVC *vc = //yada yada…make a vc.
return vc;
}
actionProvider:^UIMenu *_Nullable(NSArray<UIMenuElement*>* _Nonnull suggestedActions)
{
UIMenu *menu = [UIMenu menuWithTitle:@"" children:suggestedActions];
return menu;
}];
completionHandler(config);
}
}
else
{
completionHandler(nil);
}
}In the array of suggestedActions passed to the actionProvider block there is an action that says "Hide Link Previews". If I tap it, then take an action to show another context menu again, the next time the menu is shown the title changes to "Show Link Preview." This "toggle" doesn't seem to do anything. My guess would be clicking "Hide Link Previews" is supposed to tell the web view to save a preference to not show a preview (so ignore the view controller returned in the previewProvider block) but it doesn't do that. It appears to do nothing?