Date   

Re: Document versions browser shows windows in wrong stacking order/position

Steve Mills
 

On Oct 19, 2020, at 14:26:32, Steve Mills via groups.io <sjmills=mac.com@groups.io> wrote:

I'm trying to figure out why the versions browser is doing this weird thing with my windows. A video is linked below. The top-left corner of each window contains a timestamp for when the window gets created and the mod date of the actual file the document reads from. Notice how it ends up showing the oldest document on top after it loads all the version windows. Then as I go back through the versions, it keeps that oldest one on top. Then it starts showing the correct timestamps as I come back forward through versions. Any idea what I might be doing wrong? I'm letting NSDocument do nearly everything, and having changed any properties on the window that would screw this up.

https://www.armpitstudios.com/av/ScreenRecordingVersionsBrowserHorked.mov
Turning off "Allow debugging during browsing versions" helps this work like it should, but still not perfectly. The windows tend to appear in the right order and location, but their rendering is still out of whack. I can't tell if "Enable user interface debugging" also makes a difference.

--
Steve Mills
Drummer, Mac geek


Document versions browser shows windows in wrong stacking order/position

Steve Mills
 

I'm trying to figure out why the versions browser is doing this weird thing with my windows. A video is linked below. The top-left corner of each window contains a timestamp for when the window gets created and the mod date of the actual file the document reads from. Notice how it ends up showing the oldest document on top after it loads all the version windows. Then as I go back through the versions, it keeps that oldest one on top. Then it starts showing the correct timestamps as I come back forward through versions. Any idea what I might be doing wrong? I'm letting NSDocument do nearly everything, and having changed any properties on the window that would screw this up.

https://www.armpitstudios.com/av/ScreenRecordingVersionsBrowserHorked.mov

--
Steve Mills
Drummer, Mac geek


Re: iCloud question: CloudKit vs. NSFileManager

Leo
 

Ok perfect - thanks Jens - that's exactly what I needed to know.

Leo


Re: iCloud question: CloudKit vs. NSFileManager

 



On Oct 12, 2020, at 10:19 PM, Leo <leo.r@...> wrote:

As far as I understand, there are two ways to implement iCloud: CloudKit and NSFileManager iCloud methods.

I would use NSFileManager. CloudKit is for storing a server-side database that supports queries, indexes and sharing … that's overkill for a simple settings file.

Also, I believe if you use the NSFileManager API the user will be able to see the settings file in the Files app (or the Finder), which could be convenient.

—Jens


iCloud question: CloudKit vs. NSFileManager

Leo
 

A question for those experienced in iCloud:
 
I want to implement some very basic iCloud tasks in my apps. Just to sync a few XML files that contain settings presets. So that the users can access their presets from anywhere.
 
The presets don't have to be kept in sync at any given moment - just updated when the user loads a specific preset.
 
As far as I understand, there are two ways to implement iCloud: CloudKit and NSFileManager iCloud methods.

It looks to me that NSFileManager is sufficient for what I need.

Is that correct - or should I use CloudKit?


Thanks for any info!

Leo


NSMetadataQuery results property

Steve Mills
 

The shows this property:

@property (readonly, copy) NSArray *results; // this is for K-V Bindings, and causes side-effects on the query

Anybody know what the cryptic comment means about side-effects?

Just trying to figure out the best way to display the results (real-time as they come in) in an NSTableView.

--
Steve Mills
Drummer, Mac geek


Re: bonjour broken in iOS 14

Gerriet M. Denkmann
 

On 19 Sep 2020, at 07:51, Jens Alfke <jens@mooseyard.com> wrote:

On Sep 18, 2020, at 5:46 PM, Gerriet M. Denkmann <gerriet@mdenkmann.de> wrote:

I watched "WWDC 2020 - Support local network privacy in your app” and found out that in iOS 14 the Info.plist needs additional info:
Oh, right! It's the "Access local network" permission. I've seen that pop up.

The Info.plist key must be required only if you build the app against the iOS 14 SDK, right? Otherwise that would break existing apps.
Correct. Older apps (build with some SDK < 14) get the default value for "Privacy - Local Network Usage Description” and do not require "Bonjour services” when run in iOS 14.

Gerriet.


Re: bonjour broken in iOS 14

 



On Sep 18, 2020, at 5:46 PM, Gerriet M. Denkmann <gerriet@...> wrote:

I watched "WWDC 2020 - Support local network privacy in your app” and found out that in iOS 14 the Info.plist needs additional info:

Oh, right! It's the "Access local network" permission. I've seen that pop up.

The Info.plist key must be required only if you build the app against the iOS 14 SDK, right? Otherwise that would break existing apps.

—Jens


Re: bonjour broken in iOS 14

Gerriet M. Denkmann
 

On 19 Sep 2020, at 01:40, Jens Alfke <jens@mooseyard.com> wrote:

On Sep 18, 2020, at 2:34 AM, Gerriet M. Denkmann <gerriet@mdenkmann.de> wrote:

But in iOS 14 the stateUpdateHandler gets a .failed NWBrowser.State, with DNS Service Error: NoAuth(-65555)
I watched "WWDC 2020 - Support local network privacy in your app” and found out that in iOS 14 the Info.plist needs additional info:

• Privacy - Local Network Usage Description
if not present - then some default is used: “This app will be able to discover and connect to devices on the networks you use"
• Bonjour services
if this is missing, the app gets a .failed NWBrowser.State, with DNS Service Error: NoAuth(-65555)

Also new in iOS 14: waiting: NWError: -65570: PolicyDenied = User has refused access to Local Network


Gerriet.


Re: bonjour broken in iOS 14

 



On Sep 18, 2020, at 2:34 AM, Gerriet M. Denkmann <gerriet@...> wrote:

But in iOS 14 the stateUpdateHandler  gets a .failed NWBrowser.State, with DNS Service Error: NoAuth(-65555)

I'm guessing your network environment includes a DNS server that supports DNS updates (i.e. wide-area Bonjour) but you don't have the credentials to push updates to the DNS server.

This error probably only applies to the browser registration for that domain, not for the local-network domain. I.e. your app should still be working for local network browsing.

If you only want to do local-network (mDNS) browsing, then use `domain: "local"` instead of `domain: nil`.

—Jens

Disclaimer: I've never used the "NW" classes, I'm just working off my knowledge of Bonjour.


bonjour broken in iOS 14

Gerriet M. Denkmann
 

This worked up to iOS 13:

let serviceType = "_Gmd-BackGround._tcp."
let parameters = NWParameters()
parameters.includePeerToPeer = true
let browser = NWBrowser(for: .bonjour(type: serviceType, domain: nil), using: parameters )
browser.stateUpdateHandler =
{ (newState: NWBrowser.State) in

print(“\newState”)
}
browser.start(queue: queue)

But in iOS 14 the stateUpdateHandler gets a .failed NWBrowser.State, with DNS Service Error: NoAuth(-65555)

How can this be fixed?

Gerriet.


Re: custom table row selection highlights - my bug or Apple's?

James Walker
 

On Sep 15, 2020, at 3:05 PM, Alex Zavatone via groups.io <zav=mac.com@groups.io> wrote:

Can you set the background to needsRefresh?
I assume you mean needsDisplay. In my tableViewSelectionDidChange: delegate method, if instead of setting needsDisplay on the table, I say

[self.table enumerateAvailableRowViewsUsingBlock:
^(__kindof NSTableRowView * _Nonnull rowView, NSInteger row)
{
rowView.needsDisplay = YES;
}];

then it does show my highlights. Seems a little baroque, but it works, so thanks!



On Sep 15, 2020, at 4:54 PM, James Walker <list2@jwwalker.com> wrote:

I have a view-based NSTableView in a scroll view. I want to customized the way that selection highlighting is drawn. So, I set up a controller as a delegate of the table, and in the delegate method tableView:rowViewForRow: I provide an instance of a subclass of NSTableRowView, call it NameRowView. NameRowView overrides one method:

- (void) drawBackgroundInRect: (NSRect) dirtyRect
{
NSLog(@"drawBackgroundInRect %@", self);
if (self.selected)
{
[NSColor.greenColor setFill];
}
else
{
[NSColor.yellowColor setFill];
}
NSRectFill( self.bounds );
}

The table delegate also overrides tableViewSelectionDidChange: to call setNeedsDisplay on the table. Now, if I click or use arrow keys, tableViewSelectionDidChange: does get called, but my drawBackgroundInRect: is not called.

However, if I make the window containing the table change its “main” status, then some drawBackgroundInRect: calls finally happen.

And here’s the really weird part: If I create a WindowRef for the window containing the table, like

[self.window windowRef];

then from then on I see the selection highlight changes immediately.






Re: custom table row selection highlights - my bug or Apple's?

Alex Zavatone
 

Can you set the background to needsRefresh?

On Sep 15, 2020, at 4:54 PM, James Walker <list2@jwwalker.com> wrote:

I have a view-based NSTableView in a scroll view. I want to customized the way that selection highlighting is drawn. So, I set up a controller as a delegate of the table, and in the delegate method tableView:rowViewForRow: I provide an instance of a subclass of NSTableRowView, call it NameRowView. NameRowView overrides one method:

- (void) drawBackgroundInRect: (NSRect) dirtyRect
{
NSLog(@"drawBackgroundInRect %@", self);
if (self.selected)
{
[NSColor.greenColor setFill];
}
else
{
[NSColor.yellowColor setFill];
}
NSRectFill( self.bounds );
}

The table delegate also overrides tableViewSelectionDidChange: to call setNeedsDisplay on the table. Now, if I click or use arrow keys, tableViewSelectionDidChange: does get called, but my drawBackgroundInRect: is not called.

However, if I make the window containing the table change its “main” status, then some drawBackgroundInRect: calls finally happen.

And here’s the really weird part: If I create a WindowRef for the window containing the table, like

[self.window windowRef];

then from then on I see the selection highlight changes immediately.


custom table row selection highlights - my bug or Apple's?

James Walker
 

I have a view-based NSTableView in a scroll view. I want to customized the way that selection highlighting is drawn. So, I set up a controller as a delegate of the table, and in the delegate method tableView:rowViewForRow: I provide an instance of a subclass of NSTableRowView, call it NameRowView. NameRowView overrides one method:

- (void) drawBackgroundInRect: (NSRect) dirtyRect
{
NSLog(@"drawBackgroundInRect %@", self);
if (self.selected)
{
[NSColor.greenColor setFill];
}
else
{
[NSColor.yellowColor setFill];
}
NSRectFill( self.bounds );
}

The table delegate also overrides tableViewSelectionDidChange: to call setNeedsDisplay on the table. Now, if I click or use arrow keys, tableViewSelectionDidChange: does get called, but my drawBackgroundInRect: is not called.

However, if I make the window containing the table change its “main” status, then some drawBackgroundInRect: calls finally happen.

And here’s the really weird part: If I create a WindowRef for the window containing the table, like

[self.window windowRef];

then from then on I see the selection highlight changes immediately.


Re: Anyone using CloudKit?

 



On Sep 1, 2020, at 10:38 AM, Jens Alfke <jens@...> wrote:

#2: How the heck does one write tests for CloudKit? … The only real solution I can imagine is to mock the entire CK API, which is feasible since it seems to be implemented in Obj-C, but that would be a big effort and you'd have to reproduce all the behaviors of the real system, which aren't documented.

I've made some progress on mocking by defining a protocol containing the CKDatabase methods I call; an empty extension to mark CKDatabase as implementing that protocol; and a mock class that implements the protocol. Then in my code I just change references to `CKDatabase` to `IndirectCKDatabase`, and allow the instance to be injected.

public protocol IndirectCKDatabase : AnyObject {
    var databaseScope: CKDatabase.Scope { get }
    func add(_ operation: CKDatabaseOperation)
    func save(_ record: CKRecord, completionHandler: @escaping (CKRecord?, Error?) -> Void)
    func delete(withRecordID recordID: CKRecord.ID, completionHandler: @escaping (CKRecord.ID?, Error?) -> Void)
}

extension CKDatabase : IndirectCKDatabase}

class MockCKDatabase : IndirectCKDatabase {
    ...
}

But in implementing the mock class I'm running into roadblocks:
  • The implementation of `add` needs to add metadata (dates, changeTag) to the CKRecord. But there's no way to create this metadata. The properties have no setters, and the only way to instantiate a record with metadata is to pass in an archived copy of the metadata, which can only be produced from a CKRecord that already has it…
  • Various operations need to return CKServerChangeToken instances. There's no way to create these at all, the class has no constructor.

I've been searching for other people's solutions to mocking, and it seems various people have gone down this road, but I haven't found anyone whose gotten farther than I have :(

—Jens


Re: Anyone using CloudKit?

Bill Pitcher
 

when I was working on CloudKit I made a separate User account on my Mac with my developer Apple ID, iCloud enabled, then you can see and test the Cloud data using the browser interface.

I found it straight forward once I realised this.

cheers
Bill

On 2 Sep 2020, at 3:38 am, Jens Alfke <jens@mooseyard.com> wrote:

Hey, is anyone here using CloudKit? I'm getting started with it and have issues. There's some content on Apple's dev forums, but frankly even the new improved forums have awful UX (why couldn't they have simply used Discourse?)

#1: My Apple developer account is not the same as my regular Apple ID. That means the records my app creates are associated with my regular ID, so when I go to the CloudKit Dashboard I can't look inside the private database because I'm signed in with a different ID.

#2: How the heck does one write tests for CloudKit? The server-side environment is super test-unfriendly since there's no way to programmatically set up a clean slate. The only way to get a fresh empty database is to go to the Dashboard and manually press a button to nuke the entire dev container. The only real solution I can imagine is to mock the entire CK API, which is feasible since it seems to be implemented in Obj-C, but that would be a big effort and you'd have to reproduce all the behaviors of the real system, which aren't documented.

—Jens

PS: Cross-posted to the Apple cocoa-dev list; sorry for the duplication.


Re: Anyone using CloudKit?

Alex Zavatone
 

A specific test zone, perhaps when running in the test configuration?

Do you have a helper that can detect the build configuration used to run your app?  I posted some a while ago and can repost if you want.

I’m sure you already have this though.

- Alex Zavatone

On Sep 1, 2020, at 4:32 PM, Jens Alfke <jens@...> wrote:



On Sep 1, 2020, at 10:38 AM, Jens Alfke <jens@...> wrote:

#2: How the heck does one write tests for CloudKit? The server-side environment is super test-unfriendly since there's no way to programmatically set up a clean slate.

I've come up with a solution for this: I can't erase containers/databases, but I can erase a zone by sending a delete followed by a create. That's fine for my purposes because all my code so far operates on a single zone. I just have to start each test with an erase, and make sure tests don't run concurrently. 

To scale this to multiple developers/devices/bots, I'd need to come up with a unique zone name for each device's tests.

—Jens


Re: Anyone using CloudKit?

 



On Sep 1, 2020, at 10:38 AM, Jens Alfke <jens@...> wrote:

#2: How the heck does one write tests for CloudKit? The server-side environment is super test-unfriendly since there's no way to programmatically set up a clean slate.

I've come up with a solution for this: I can't erase containers/databases, but I can erase a zone by sending a delete followed by a create. That's fine for my purposes because all my code so far operates on a single zone. I just have to start each test with an erase, and make sure tests don't run concurrently. 

To scale this to multiple developers/devices/bots, I'd need to come up with a unique zone name for each device's tests.

—Jens


Re: Anyone using CloudKit?

Alex Zavatone
 

I seem to recall that Axel Kee on Twitter completed a project that might be related to this.  He’s in Singapore and is at @soulchildpls on Twitter.

But you know Apple.  It would probably be best to make up a dev account that is only used for testing this.

GL.  I’ll warn/let Axel know that you might be asking him a question.

Cheers,
Alex Zavatone

On Sep 1, 2020, at 12:38 PM, Jens Alfke <jens@...> wrote:

Hey, is anyone here using CloudKit? I'm getting started with it and have issues. There's some content on Apple's dev forums, but frankly even the new improved forums have awful UX (why couldn't they have simply used Discourse?)

#1: My Apple developer account is not the same as my regular Apple ID. That means the records my app creates are associated with my regular ID, so when I go to the CloudKit Dashboard I can't look inside the private database because I'm signed in with a different ID.

#2: How the heck does one write tests for CloudKit? The server-side environment is super test-unfriendly since there's no way to programmatically set up a clean slate. The only way to get a fresh empty database is to go to the Dashboard and manually press a button to nuke the entire dev container. The only real solution I can imagine is to mock the entire CK API, which is feasible since it seems to be implemented in Obj-C, but that would be a big effort and you'd have to reproduce all the behaviors of the real system, which aren't documented.

—Jens

PS: Cross-posted to the Apple cocoa-dev list; sorry for the duplication.




Anyone using CloudKit?

 

Hey, is anyone here using CloudKit? I'm getting started with it and have issues. There's some content on Apple's dev forums, but frankly even the new improved forums have awful UX (why couldn't they have simply used Discourse?)

#1: My Apple developer account is not the same as my regular Apple ID. That means the records my app creates are associated with my regular ID, so when I go to the CloudKit Dashboard I can't look inside the private database because I'm signed in with a different ID.

#2: How the heck does one write tests for CloudKit? The server-side environment is super test-unfriendly since there's no way to programmatically set up a clean slate. The only way to get a fresh empty database is to go to the Dashboard and manually press a button to nuke the entire dev container. The only real solution I can imagine is to mock the entire CK API, which is feasible since it seems to be implemented in Obj-C, but that would be a big effort and you'd have to reproduce all the behaviors of the real system, which aren't documented.

—Jens

PS: Cross-posted to the Apple cocoa-dev list; sorry for the duplication.

121 - 140 of 1427