Re: Cocoa-dev Digest, Vol 14, Issue 78
Re: Cocoa-dev Digest, Vol 14, Issue 78
- Subject: Re: Cocoa-dev Digest, Vol 14, Issue 78
- From: Ide Sous Le Bois <email@hidden>
- Date: Tue, 07 Mar 2017 05:43:19 +0100
Envoyé de mon smartphone BlackBerry 10.
Message d'origine
De: email@hidden
Envoyé: lundi 6 mars 2017 14:36
À: email@hidden
Répondre à: email@hidden
Objet: Cocoa-dev Digest, Vol 14, Issue 78
Send Cocoa-dev mailing list submissions to
email@hidden
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.apple.com/mailman/listinfo/cocoa-dev
or, via email, send a message with subject or body 'help' to
email@hidden
You can reach the person managing the list at
email@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Cocoa-dev digest..."
Today's Topics:
1. Re: Issue with addTitlebarAccessoryViewController on 10.10
(Kyle Sluder)
2. Overriding the automatic-save type (Daryle Walker)
3. Enforcing Editor vs. Viewer (was: Which way should my
document class handle an older format?) (Daryle Walker)
4. boundingRectForGlyphRange is very inaccurate (Gerriet M. Denkmann)
5. Re: Issue with addTitlebarAccessoryViewController on 10.10
(Mark Allan)
6. Binding NSTextField to an array (Jeremy Hughes)
7. Re: Binding NSTextField to an array (Mike Abdullah)
8. Unicode filenames with Apple File System and
UIManagedDocument (email@hidden)
9. Re: Binding NSTextField to an array (Jeremy Hughes)
----------------------------------------------------------------------
Message: 1
Date: Sun, 05 Mar 2017 16:35:59 -0600
From: Kyle Sluder <email@hidden>
To: email@hidden
Subject: Re: Issue with addTitlebarAccessoryViewController on 10.10
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=utf-8
On Fri, Mar 3, 2017, at 08:39 AM, Mark Allan wrote:
> Hi all,
>
> I've got an NSWindow which has an NSToolbar added programmatically. The
> window does not use a shared title/toolbar. I now want to add a little
> bit of text/button to the window's titlebar, so for OS X 10.6 to 10.9,
> I'm doing it the old way playing around with NSWindow subviews, which
> works fine.
>
> On versions 10.10+ I'm using addTitlebarAccessoryViewController which
> works great on 10.11 and 10.12, but for some reason it shifts the toolbar
> buttons out of position on 10.10.
>
> Judging by the AppKit release notes, this is a known issue which was
> fixed in 10.11, and also by linking on 10.11
>
> > For applications linked on 10.11 and higher, a NSTitlebarAccessoryViewController with the layoutAttribute set to NSLayoutAttributeRight will no longer right indent toolbar items, unless the titleVisibility == NSWindowTitleHidden. This allows placing a view/button/textfield (etc) above the toolbar without right indenting the toolbar. However, for the NSWindowTitleHidden, there is still a desire to indent the toolbar on the right to leave space for the accessory view.
>
> I'm currently building on macOS 10.12 (with target of 10.6) but the issue
> still shows up for users on OS X 10.11, even with the viewcontroller's
> layoutAttribute = NSLayoutAttributeRight.
>
> Does anyone know of a fix or workaround I could use please?
Is it possible to reproduce this in a sample app? This should be
behaving as documented in the release notes.
--Kyle Sluder
>
> If it comes to it, I could still use the old subview manipulation method
> on 10.10 and users would just have to put up with seeing junk in the log
> about adding an unknown subview, but I'd rather avoid that if possible!
>
> Would appreciate any help.
>
> Many thanks
> Mark
------------------------------
Message: 2
Date: Sun, 05 Mar 2017 20:03:04 -0500
From: Daryle Walker <email@hidden>
To: Cocoa dev <email@hidden>
Subject: Overriding the automatic-save type
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
The NSDocument property “autosavingFileType” lets the developer indicate which one of the types the document class supports will be the one used for auto-saves. The notes at the website suggest that “init(for: withContentsOf: ofType:)” be overridden too. It punts to the TextEdit sample document class, but I don’t see anything that would help. However, could I use “NSDocumentController.typeForContents(of:)” to fill in the original file’s type?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
------------------------------
Message: 3
Date: Sun, 05 Mar 2017 20:08:31 -0500
From: Daryle Walker <email@hidden>
To: Cocoa dev <email@hidden>
Subject: Enforcing Editor vs. Viewer (was: Which way should my
document class handle an older format?)
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
> On Mar 4, 2017, at 3:40 AM, Daryle Walker <email@hidden> wrote:
>
> My document class reads in UTF-8 data for its internal format. The format has an older version that is ASCII-based. Since the latter is a subset of the former, my parser can handle both formats. Right now, I can’t write out in the older format. (The new format is just a text dump upon save. The old format would need to handle any post-ASCII values.)
>
> I’m wondering how I should be the old format in the Info.plist. I could put it in as a second document type. This lets me set it as “Viewer” independently of the first format being set to “Editor.” Altering the message and trying to save gives a system error about the file not being able to be saved. However, the “isInViewMode” flag doesn’t get set, so the document is editable! (But the edits can’t be saved.)
>
> The other way is to have one document type entry in the Info.plist, but put the old format as a second content type. Of course, it’ll always be in “Editor.” And the save sheet gets a pop-up menu for the format to be saved. I haven’t added an entry for exported-types in the p-list, so the menu is just the first type. The second type isn’t in the menu and if I try to duplicate the file (the new-world-order substitute for “Save As” since Lion), I get a can’t-be-saved error.
>
> I guess the second scenario seems to be what I want, but it still seems ugly. Are there any better solutions?
It seems like TextEdit does it the first way, and so does sample code in a relevant StackOverflow query, so I’m switching back.
But, does Apple's default code for NSDocument do anything differently between an “Editor” and a “Viewer”? (This can happen if a edit-type shares the same document subclass as a view-type.) Or do I have to check which mode myself and enforce editor-ness vs. viewer-ness myself?
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
------------------------------
Message: 4
Date: Mon, 06 Mar 2017 16:41:31 +0700
From: "Gerriet M. Denkmann" <email@hidden>
To: cocoa-dev <email@hidden>
Subject: boundingRectForGlyphRange is very inaccurate
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii
macOS 12.3, Xcode Version 8.2.1 (8C1002).
I am trying to get bounding rects in a TextView:
NSRange glyphRange = [ layoutManager glyphRangeForCharacterRange: someCharRange
actualCharacterRange: NULL
];
NSTextContainer *container = [ layoutManager textContainerForGlyphAtIndex: glyphRange.location
effectiveRange: NULL
];
CGRect rect = [ layoutManager boundingRectForGlyphRange: glyphRange inTextContainer: container ];
The problem:
using the ruler of the TextView I know the actual x-range of someCharRange.
But the rect is much bigger on both sides.
E.g. selecting a string which occupies 1 cm from 19 cm to 20 cm on the ruler I get a rect : 18.16 + 3.63 = 21.79
The error (not very surprisingly) depends on the font used.
How can I get a rectangle from my string which closely resembles what is seen on the screen?
Gerriet.
------------------------------
Message: 5
Date: Mon, 06 Mar 2017 12:21:57 +0000
From: Mark Allan <email@hidden>
To: Kyle Sluder <email@hidden>
Cc: email@hidden
Subject: Re: Issue with addTitlebarAccessoryViewController on 10.10
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii
> On 5 Mar 2017, at 10:35 pm, Kyle Sluder <email@hidden> wrote:
>
> On Fri, Mar 3, 2017, at 08:39 AM, Mark Allan wrote:
>> Hi all,
>>
>> I've got an NSWindow which has an NSToolbar added programmatically. The
>> window does not use a shared title/toolbar. I now want to add a little
>> bit of text/button to the window's titlebar, so for OS X 10.6 to 10.9,
>> I'm doing it the old way playing around with NSWindow subviews, which
>> works fine.
>>
>> On versions 10.10+ I'm using addTitlebarAccessoryViewController which
>> works great on 10.11 and 10.12, but for some reason it shifts the toolbar
>> buttons out of position on 10.10.
>>
>> Judging by the AppKit release notes, this is a known issue which was
>> fixed in 10.11, and also by linking on 10.11
>>
>>> For applications linked on 10.11 and higher, a NSTitlebarAccessoryViewController with the layoutAttribute set to NSLayoutAttributeRight will no longer right indent toolbar items, unless the titleVisibility == NSWindowTitleHidden. This allows placing a view/button/textfield (etc) above the toolbar without right indenting the toolbar. However, for the NSWindowTitleHidden, there is still a desire to indent the toolbar on the right to leave space for the accessory view.
>>
>> I'm currently building on macOS 10.12 (with target of 10.6) but the issue
>> still shows up for users on OS X 10.11, even with the viewcontroller's
>> layoutAttribute = NSLayoutAttributeRight.
>>
>> Does anyone know of a fix or workaround I could use please?
>
> Is it possible to reproduce this in a sample app? This should be
> behaving as documented in the release notes.
>
> --Kyle Sluder
Hi Kyle,
Yes, I've just moved all the relevant code in to a new sample app and it behaves the same way. Below is a link to the code and a three screenshots showing how it appears on 10.6, 10.10 and 10.11.
https://www.dropbox.com/s/1adygl9r8mhfn0s/TestApp_TitlebarAccesoryTrouble.zip?dl=0 <https://www.dropbox.com/s/1adygl9r8mhfn0s/TestApp_TitlebarAccesoryTrouble.zip?dl=0>
Many thanks
Mark
------------------------------
Message: 6
Date: Mon, 06 Mar 2017 13:10:06 +0000
From: Jeremy Hughes <email@hidden>
To: Cocoa Dev <email@hidden>
Subject: Binding NSTextField to an array
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
Hi,
This seems like an elementary question.
I’d like to bind an NSTextField to an array of numerical values, so that the text field will either display a single value if the values are identical or will display a multiple values marker if the values are different.
Using Swift, I can bind a text field to a single value like this:
dynamic var value = NSNumber(value: 7)
But if I try to bind to an array of values like this:
dynamic var values = [NSNumber(value: 7), NSNumber(value: 3)]
I get the following error:
Cannot create number from object (
7,
3
) of class _TtGCs23_ContiguousArrayStorageCSo8NSNumber_
How do I bind an NSTextField to an array?
Jeremy
------------------------------
Message: 7
Date: Mon, 06 Mar 2017 14:16:37 +0100
From: Mike Abdullah <email@hidden>
To: Jeremy Hughes <email@hidden>
Cc: Cocoa Dev <email@hidden>
Subject: Re: Binding NSTextField to an array
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
>From what I understand of your example, you’re not “binding” anything in a Cocoa sense.
What you is an NSArrayController. Bind your text field to the array controller. Supply the array controller with content, and have it derive the selected value, be it single or multiple.
> On 6 Mar 2017, at 14:10, Jeremy Hughes <email@hidden> wrote:
>
> Hi,
>
> This seems like an elementary question.
>
> I’d like to bind an NSTextField to an array of numerical values, so that the text field will either display a single value if the values are identical or will display a multiple values marker if the values are different.
>
> Using Swift, I can bind a text field to a single value like this:
>
> dynamic var value = NSNumber(value: 7)
>
> But if I try to bind to an array of values like this:
>
> dynamic var values = [NSNumber(value: 7), NSNumber(value: 3)]
>
> I get the following error:
>
> Cannot create number from object (
> 7,
> 3
> ) of class _TtGCs23_ContiguousArrayStorageCSo8NSNumber_
>
> How do I bind an NSTextField to an array?
>
> Jeremy
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
------------------------------
Message: 8
Date: Mon, 06 Mar 2017 08:28:59 -0500
From: email@hidden
To: "Cocoa-Dev (Apple)" <email@hidden>
Subject: Unicode filenames with Apple File System and
UIManagedDocument
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
I have an iOS app (Attendance2) written in Objective-C. One of my users upgraded to the public 10.3 iOS beta and reported he could no longer open his documents (I have a subclass of UIManagedDocument so they are Core Data files stored in the package/directory format that UIManagedDocument uses). I didn’t notice any issues with my test device using the developer beta of 10.3. He changed the file names from Arabic to Roman and then he said he could open them.
Everything I do with NSString is via UTF8 (and it worked fine with Arabic letters for this person before updating to the 10.3 beta) so I don’t think I’m doing anything wrong.
Any suggestions?
Thanks,
Dave Reed
------------------------------
Message: 9
Date: Mon, 06 Mar 2017 13:32:06 +0000
From: Jeremy Hughes <email@hidden>
To: Mike Abdullah <email@hidden>
Cc: Cocoa Dev <email@hidden>
Subject: Re: Binding NSTextField to an array
Message-ID: <email@hidden>
Content-Type: text/plain; charset=utf-8
> From what I understand of your example, you’re not “binding” anything in a Cocoa sense.
In the case of the single value, the text field is set up via the Bindings pane of Interface Builder so that “Value" says “Bind to File’s Owner” with a model key path of self.value. (And “value" is declared as dynamic so that Swift will take care of KVO.) This works fine. Is this not a Cocoa binding?
What I don’t understand is why this works for a single value but doesn’t work for an array of values, where I change the model key path to self.values.
> What you is an NSArrayController. Bind your text field to the array controller. Supply the array controller with content, and have it derive the selected value, be it single or multiple.
OK. I now have an array controller that is bound to File’s Owner with a model key path of self.values, and I then bind the text field to the array controller with a Controller Key value of “selection” (although I’m not sure that’s right, because the array is not actually displayed anywhere for users to select items).
Now I get the following error:
Cannot create number from object <_NSControllerObjectProxy: 0x6000000070b0> of class _NSControllerObjectProxy
Jeremy
------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins (at) lists.apple.com
https://lists.apple.com/mailman/listinfo/cocoa-dev
End of Cocoa-dev Digest, Vol 14, Issue 78
*****************************************
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden