Code signing checking

2023-01-06 Thread Aandi Inston via Cocoa-dev
Is there any API for doing the following activities related to code
signing?
- Check that the signature on the running codesigned executable is from the
same company as the signature on a bundle?
OR
- Get the company from the codesigned running executable and
- Get the company from a signature on a bundle
(so we can check they are the same).

I think this can be done calling and reading output from the codesign CLI,
but an API seems tidier.

Reference to detailed reading is fine!!
Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Are runtimes of system objects dynamic/SDK dependent/whatever?

2022-06-14 Thread Aandi Inston via Cocoa-dev
I'm trying to understand how Mac OS X actually implements the predefined
objects like NSApplication. Not in detail by function, but where the code
lives. This is by way of understanding what happens if the SDK version
doesn't match the system version. Let's suppose I would like to use an
imaginary method [NSApplication doCoolStuff] which was added in Mac OS
10.15, but I'm linking with the 10.14 SDK.

So, where does doCoolStuff actually exist? I can think of several
possibilities.

1. The code for NSApplication and its methods is linked entirely into my
application. This makes it self contained, though it might depend on system
calls and external services. So NSApplication exists inside my application,
and it runs the version written as part of the SDK I link with (10.14).
There is no way for me to call   [NSApplication doCoolStuff]  , because it
doesn't exist in the NSApplication I am using (10.14 runtime).

2. The code for NSApplication is dynamically linked from system-provided
shared code of some kind, using the same code regardless of the SDK version
used. The shared code may include some differences according to info it has
on the SDK used to build the current app. In this case perhaps I could call
[NSApplication doCoolStuff], though not by coding that; something involving
NSSelectorFromString.

3. The code for NSApplication is dynamically linked from system-provided
shared code of some kind, using code dependent on the SDK version used. The
methods provided will depend on the SDK version used. This would imply
that, like case 1, is no way for me to call  [NSApplication doCoolStuff]  ,
because it doesn't exist in the NSApplication runtime I am using.

4. The code for NSApplication is a stub to some other kind of external
interface I never heard of...

Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem with rangeOfString and Umlauts

2022-03-14 Thread Aandi Inston via Cocoa-dev
This is largely from memory, so details might be wrong.
Normalisation is an insufficiently known thing to consider when working
with Unicode.  (We all know that Unicode is a list of code points
(integers).

Here are some Unicode points for this discussion:
U+0065 "e" Latin Small Letter E
U+00E9 "é" Latin Small Letter E with Acute
U+0301 "◌́" (U+0301) Combining Acute accent - this may not display as
expected and may show a "ghost" dotted circle you won't see.
Many languages have accents that change letters, so we have "e" plus
"acute" to get "e acute". In Unicode there are two ways to get "e acute".
One is the single Unicode point U+00E9. The other is the TWO characters "e"
and "combining acute accent", so U+0065 followed by U+0301. U+0301 does not
take any space for itself, but dumps an acute accent over the character
before.(Not all accented letters have two representations like this, and
some have more than two).
So, what's the difference between U+00E9 versus U+0065 followed by U+0301?
They will look the same, but a string with the second form will be 1
character longer, and the offset of all character after it will be changed.
Are they equal? Well, no, not in simple terms because they are different
list of characters.
Do we get both? YES. The Mac OS file systems store the long form. On a
French keyboard, if you type e acute, you get the short form. If you copy
paste it could be either. This can be bad. For example if you get a list of
the files in a folder, and allow the user to type a name to choose the
file, there might not be a match, even though the user can see one.
To get over this, we have "canonical" forms. There are at least four forms,
C, D, KC and KD. precomposedStringWithCanonicalMapping converts to form C.
It doesn't really matter what it is, but if you run all your strings
through precomposedStringWithCanonicalMapping, then you will get more
expected results when comparing strings.

On Mon, 14 Mar 2022 at 13:05, Gabriel Zachmann via Cocoa-dev <
cocoa-dev@lists.apple.com> wrote:

> >
> > It’s hard to tell from the above snippet, but I suspect your strings are
> different in normalization.
>
> I suspected that, too, but I have no expertise in normalization.
>
> > Specifically, I suspect that file_basename uses two Unicode codepoints
> for the ä, and info_item uses only one.
> >
> > As an experiment, try running both strings through
> -precomposedStringWithCanonicalMapping before doing
>
> Thanks a lot!
> That seems to solve the problem.
> I have looked up the documentation of the method, but I don't really
> understand it.
> Could you explain it to me?
>
>
> To gain more insights (I usually think it's better to understand in depth
> what one is doing),
> here is some more background info:
>
> One of the strings is derived from a path, like so:
>
> query_ = [[NSMetadataQuery alloc] NSPredicate * predicate = [NSPredicate
> predicateWithFormat: @"(kMDItemContentTypeTree = 'public.image')" ];
> [query_ setSearchScopes: [NSArray arrayWithObject:
> mainDirectoryLocation_]];
> [query_ setPredicate: predicate];
> [query_ startQuery];
>  .
> NSString * img_filename = [[query_ resultAtIndex: i] valueForAttribute:
> @"kMDItemPath"];
> file_basename = [[img_filename lastPathComponent]
> stringByDeletingPathExtension];
>
>
>
> The other string is derived from EXIF data, like so:
>
> CFDictionaryRef tiff_dict;
> CFDictionaryGetValueIfPresent( fileProps, kCGImagePropertyTIFFDictionary,
> (const void **) & tiff_dict );
>
> CFDictionaryGetValueIfPresent( tiff_dict,
> kCGImagePropertyTIFFImageDescription,
>  (const void **) &
> caption );
> info_item = [[NSString alloc] initWithString: (__bridge NSString *
> _Nonnull)(caption)];
>
>
> Could that explain the funny handling of umlauts I am seeing?
>
> In particular, in the debugger, I can see that the type of  file_basename
> is actually an (NSPathStore2 *).
> Could that be a problem?
>
>
>
> Thanks a lot in advance.
>
> Best regards, Gabriel
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Performance issue on macOS 10.15 obtaining display name for ~/Desktop, ~/Documents, and ~/Downloads

2020-05-22 Thread Aandi Inston via Cocoa-dev
Your report is interesting. I have been following it but may have missed a
part of the discussion, so here is one
thought I had. You say that getting the display name of ~/Documents may
result in a delay. This is localizable, so
that in Portugal (for example) the display name is Documentos. So here are
thoughts
1. I wonder if your tests are in a non-English language system.
2. I wonder if in an English language system there is a fast path that
tells the system to bypass localization tests.
3. I wonder if the other testers who could not reproduce this were using an
English language system.
I observe that the internet says (so it must be true) that the test for
localized folders is a hidden file in the folder
called ".localized". To check for this in any obvious way is going to need
read access to the folder, and hence may
trigger security checking.

On Fri, 22 May 2020 at 15:43, Allan Odgaard via Cocoa-dev <
cocoa-dev@lists.apple.com> wrote:

> On 23 Apr 2020, at 21:15, Rob Petrovec wrote:
>
> > If what you say is correct then everyone would be seeing a delay since
> > most people don’t have blazing fast internet connections.  I do not
> > think this is the normal behavior.  I think it is specific to your
> > system, otherwise there would be TONS of people complaining about
> > slowness.
>
> Episode 379 of ATP has just been released and both Marco Arment and John
> Siracusa are complaining about significant delays after upgrading to
> macOS 10.15, though for John Siracusa I think only one of his machines
> has the problem.
>
> Also, I think I already mentioned it, but I had a friend of mine run
> tests on his machine in another geographical zone, and he saw delays as
> well.
>
> > Either way, did you file a bug with a sysdiagnose taken during the
> > delay?  If so, do you have the bug number?
>
> Several people in this thread were asking for bug numbers: I do not
> understand this, no-one outside of Apple can read these bugs, right?
>
> But now I wrote up a summary of what I have found so far with bug
> numbers included:
> https://sigpipe.macromates.com/2020/macos-catalina-slow-by-design/
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Not seeing rightMouseDown: - what are the docs actually saying ?

2019-10-21 Thread Aandi Inston via Cocoa-dev
Thank you very much for taking the time to build a test and make a reply.
I don't (in general) actually have custom subviews. The clicks were tested
(among other places) in parts of the NSWindow to which I have not
explicitly added content, as well as standard classes like NSBox. I was
suggesting I might have to make subclassed NSViews to pick up
rightMouseDown: events. But is it even knowable what NSViews lay between a
click and a window? Most obviously there is the [NSWindow contentView], but
some other view types may contain their own subviews which could receive
events.

I build the 32-bit plug-in with XCode 9.2, link with SDK 10.13 and
deployment target 10.7. So certainly it's linked on macOS 10.7 or later.
But I rather suspect that the "linked on" which matters is the host app,
which otool shows (for the most recent) as
cmd LC_VERSION_MIN_MACOSX
version 10.6
sdk n/a
I suspect that this app may not pass whatever the " linked on macOS 10.7 or
later" test is looking for, and my plug-in cannot change the behaviour of
Cocoa classes it inherits from the app.

Rather than chase down all the NSViews for which I might need to create
subclasses, I think the alternative of using rightMouseUp: seems to work
well enough on both 16 and 32 bits. So, I'm happy to consider this closed.
Thanks again.

On Mon, 21 Oct 2019 at 20:17, Richard Charles  wrote:

> > On Oct 20, 2019, at 8:27 AM, Aandi Inston  wrote:
> >
> > We have a workaround, which is to move our right click processing onto
> MouseUp, which is passed up the responder chain as we wish in both 32 and
> 64 bit systems. But I remain curious as to what the docs are actually
> telling me.
>
> From NSResponder documentation.
>
> "Prior to OS X v10.7, NSView did not pass unhandled rightMouseDown(with:)
> events up the responder chain. In macOS 10.7 and later, NSView passes
> rightMouseDown(with:) events up the responder chain if AppKit doesn’t find
> an associated context menu to display for the view. To avoid binary
> compatibility issues, this new behavior is enabled only for applications
> linked on macOS 10.7 or later."
>
> Sounds straight forward to me. Perhaps you need to read it again.
>
> I created a new app with Xcode 9.2 and linked to 10.13. Created a custom
> view and custom window with rightMouseDown logging. Built the app for 32
> bit and 64 bit. An unhandled rightMouseDown is passed promptly from view to
> window in both cases.
>
> Also the NSView documentation states.
>
> "Because NSView changes the default behavior of the rightMouseDown:
> method, you should call super when implementing that method in your custom
> subclasses."
>
> Are you doing this?
>
> --Richard Charles
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Not seeing rightMouseDown: - what are the docs actually saying ?

2019-10-20 Thread Aandi Inston via Cocoa-dev
" Why are you compiling a plugin for 32 bits?" Because plug-ins must match
the host app. In this case the host app's 64 bit version was only released
4 years ago. (The host app is made by a third party).
Older versions of the app run on 10.14 and are still widely used by our
customers. So, while we are delighted to be making a 64 bit plugin and
supporting our customers going onto Catalina, we so no reason to stop
selling stuff to those running the older app.
We'll be watching numbers as we decide how long to keep doing this.

We have a workaround, which is to move our right click processing onto
MouseUp, which is passed up the responder chain as we wish in both 32 and
64 bit systems. But I remain curious as to what the docs are actually
telling me.

> I believe I may be seeing an effect described in the Cocoa docs for the
> rightMouseDown: method. I am unsure exactly what the docs are saying
> however. Symptom: compiled for 64-bits, an unhandled rightMouseDown: is
> eventually sent to the NSWindow subclass, but compiled for 32-bits (and run
> on 10.11.6 at least) the event never arrives.
> >
> > For NSView, we see "In macOS 10.7 and later, if the event is not
> handled, this method passes it up the responder chain." For NSResponder we
> see "Prior to OS X v10.7, NSView did not pass unhandled rightMouseDown:
> events up the responder chain. In macOS 10.7 and later, NSView passes
> rightMouseDown: events up the responder chain if AppKit doesn’t find an
> associated context menu to display for the view. To avoid
> binarycompatibility issues, this new behavior is enabled only for
> applications linked on macOS 10.7 or later."
> >
> > But what is the actual test for whether to do this? "Running on" and
> "linked on" are both 10.11. Is it actually looking at the "Deployment
> target"? To make matters worse, my code is running as a plug-in and I'm
> going to take a guess that if a deployment target applies, it is the one
> selected in the main executable (not under my control) rather than the
> plug-in... can anyone explain what Cocoa would be looking at?
> >
> > And if it turns out that I'm not going to get rightMouseDown: sent
> directly to my NSWindow, is there any alternative to subclassing any NSView
> or descendent (including NSControls of various flavours) that might be the
> initial responder?
> >
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Not seeing rightMouseDown: - what are the docs actually saying ?

2019-10-18 Thread Aandi Inston via Cocoa-dev
I believe I may be seeing an effect described in the Cocoa docs for the
rightMouseDown:
method. I am unsure exactly what the docs are saying however. Symptom:
compiled for
64-bits, an unhandled rightMouseDown: is eventually sent to the NSWindow
subclass,
but compiled for 32-bits (and run on 10.11.6 at least) the event never
arrives.

For NSView, we see "In macOS 10.7 and later, if the event is not handled,
this method
passes it up the responder chain." For NSResponder we see "Prior to OS X
v10.7, NSView
did not pass unhandled rightMouseDown: events up the responder chain. In
macOS 10.7 and
later, NSView passes rightMouseDown: events up the responder chain if
AppKit doesn’t
find an associated context menu to display for the view. To avoid binary
compatibility
issues, this new behavior is enabled only for applications linked on macOS
10.7 or
later."

But what is the actual test for whether to do this? "Running on" and
"linked on" are
both 10.11. Is it actually looking at the "Deployment target"? To make
matters worse,
my code is running as a plug-in and I'm going to take a guess that if a
deployment
target applies, it is the one selected in the main executable (not under my
control)
rather than the plug-in... can anyone explain what Cocoa would be looking
at?

And if it turns out that I'm not going to get rightMouseDown: sent directly
to my
NSWindow, is there any alternative to subclassing any NSView or descendent
(including
NSControls of various flavours) that might be the initial responder?

Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSScrollView showing part of view with white space above

2019-10-13 Thread Aandi Inston via Cocoa-dev
No auto-layout, identical coordinate systems. I found the solution, which
is entirely my fault of course, thanks
to your comment "It sounds like your NSView actually has white space at the
top." For the benefit of future
readers of this thread, here is the solution.

I assumed the underlying (scrolled) NSView must be correct because it
always was correct when shown without
the NSScrollView. (The NSScrollView was added only if the window layout
would not fit on screen). But, the
window was created from coordinates that are top down (origin top left).
This has been managed before using
any Cocoa code by something like this:

  cocoa_y = window_interior_height - design_y

but of course, the window_interior_height is no longer interesting. I was
subtracting from too small a number,
and needed to be subtracting from the size assigned to the scrolled area.
So I really, really did have a
scrolled area with lots of white space at the top. Thank you for sending me
straight to the solution!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSScrollView showing part of view with white space above

2019-10-13 Thread Aandi Inston via Cocoa-dev
I have having a problem working with NSScrollView. The code is in pieces
all over
the desk at the moment, but I'm asking in case someone recognises the
symptoms,
before I reduce this to a simple test case.

An NSScrollView is made from an NSView containing various NSControls. The
NSView
is fine before the NSScrollView and, when the NSScrollView is shown, looks
fine.
It shows the top portion of the NSView, as expected.

But, the vertical scroll bar position is at the BOTTOM of the window. Now,
the
curious part starts. If the NSScrollView is scrolled upwards, the content in
the window moves down (as normal). What we now see is a large white space
at the
top of the NSScrollView, and below that the same view portion we first saw.

To put it another way, the NSView we scroll is a view containing white
space at
the top, and part of the original NSView below that. Yet all the rectangles
I
can find show (0,0) as the origin as I'd expect.

Note that this is NOT a question about how to make the scroll bar first
appear
at the top. If I use [myScrollView.contentView
scrollPoint:NSMakePoint(0,height)]
I get the same effect as dragging the scroll bar to the top.

Maybe ASCII art can explain

Complete NSView (to be scrolled)
+-
+
+  TOP LABEL
+
+  Explanation
+
+  [x] Check box
+
+  {Cancel} {OK}
+
+-

Initial NSScrollView (scroll bar shown at BOTTOM)
+-
+
+  TOP LABEL
+
+  Explanation
+
+  [x] Check box
+---

Effect of moving scroll bar to the top
+-
+
+
+
+
+  TOP LABEL
+
+---

Scrolling does not make the Cancel and OK buttons appear at all.

Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Thoughts on Cocoa source code

2019-10-09 Thread Aandi Inston via Cocoa-dev
" . Cocoa is part of the OS, and changes one very OS release. "

This reminds me of a question which pops up for me every few years in
development. I can't call to mind the last
specific details, but it will happen again.
Let's create an imaginary problem:
* Apple add a new class behaviour to Cocoa in macOS 10.15. We'll suppose
they add [NSApplication doUsefulThing]
* But for whatever reason, I'm using the Mac OS 10.14 SDK. So that will get
a compile-time warning. Still, I'd
really like to do the useful thing anyway, and without changing the SDK for
whatever reason.
* I add a check for actual OS version, so I am very sure not try to call
[NSApplication doUsefulThing]
unless the OS is 10.15 or later.
* But what happens if it runs in 10.15? Does it actually do the useful
thing?
Are the Cocoa methods entirely dynamically loaded/provided by the live OS?
Or does anything get statically linked,
flagged, is the binary's SDK version checked or is there anything else that
will prevent this call doing the
useful thing?

Thanks in advance!

On Wed, 9 Oct 2019 at 18:42, Jens Alfke via Cocoa-dev <
cocoa-dev@lists.apple.com> wrote:

>
>
> > On Oct 9, 2019, at 10:19 AM, Turtle Creek Software via Cocoa-dev <
> cocoa-dev@lists.apple.com> wrote:
> >
> > Why is Cocoa source code hidden?
>
> So, take this as opinions of someone who worked at Apple, on [among other
> things] Mac OS X apps from 2000-2007.
>
> (a) It's part of Apple's crown jewels and seen as a competitive advantage.
> (b) It calls all sorts of internal APIs of lower-level components like the
> WindowServer, and Apple doesn't want to expose those APIs because they're
> undocumented, easily misused, hard to support, subject to change at any
> moment, etc.
> (c) If developers look at the source code they'll be tempted to make use
> of undocumented behaviors, private methods, etc. which makes their apps
> much more likely to break in future OS versions. (This already does happen,
> to an extent, but with source code it would be much more pervasive, given
> the dynamic nature of Obj-C and how easy it is to call internal methods or
> even patch system classes.)
> (d) Internal source code tends to have comments and identifiers that refer
> to internal code names, canceled projects, and other stuff that shouldn't
> be made public. Sanitizing this is a pain.
> (e) Apple obviously works on lots of features that remain secret for
> months or years; these would all have to be kept in private branches,
> causing all sorts of merging/rebasing headaches.
> (d) It takes quite a lot of effort to maintain a large open source
> project. It's not just dumping the source to Github.
>
> > Yeah, the headers are visible, and Apple has
> > info online. But sometimes that was not sufficient to understand the
> actual
> > implementation details.
>
> You don't want to use the _implementation_ details! Those can and do
> change completely over time — I know NSView has been
> redesigned/reimplemented at least twice since 2000 — so making use of them
> on OS version N could cause your app to break in version N+1. You want to
> know the details of the (defined) _behaviors_. That means better
> documentation. I agree that Apple could improve here.
>
> > When debugging, the stack trace inside Cocoa was just a bunch of
> > rarely-helpful Assembly. No way to set breakpoints inside Cocoa classes
>
> That's not true; you can use symbolic breakpoints to break on any
> Objective-C method, or any C function that has a visible symbol.
>
> > I personally learned C++ while using the PowerPlant library from
> Metrowerks.
>
> The difference is that PP is code that you link statically into your app.
> It doesn't change versions unless you explicitly update it. Cocoa is part
> of the OS, and changes one very OS release. Binary compatibility is super
> important to Apple, so Cocoa being a "black box" is actually a feature, not
> a bug.
>
> —Jens
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Deep linking from 1 tvOS app to another

2017-06-17 Thread Aandi Inston
> Actually don’t do the substitution by hand. Let NSString URL-encode it
for you. Otherwise your URL will break again when someone decides to type a
“/“ or “#”, etc. into your text field.

This is an interesting point. A / is actually legal in a URL but has
specific semantics, while space just isn't allowed. If the URL is a private
scheme where both ends are under your control and / is not used as a
separator, it might work.
Still, the easiest thing is to just use a supplied encode/decode. Consider
especially what might happen to non-roman characters (someone
copy-pastes naïve or café or smart quotes). I wouldn't know what to do with
these, but I bet the encoder does.

On 16 June 2017 at 20:15, Jens Alfke  wrote:

>
> > On Jun 16, 2017, at 8:00 AM, Eric E. Dolecki  wrote:
> >
> >let modified = supplied.replacingOccurrences(of: " ", with:
> "+")
>
> Don’t use “+”, use “%20”. The “+” is only valid in some contexts IIRC,
> like form values.
>
> Actually don’t do the substitution by hand. Let NSString URL-encode it for
> you. Otherwise your URL will break again when someone decides to type a “/“
> or “#”, etc. into your text field.
>
> —Jens
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Deep linking from 1 tvOS app to another

2017-06-16 Thread Aandi Inston
Spaces are not legal in a URL. So failure or unpredictable results is
expected. See for example discussion here
https://stackoverflow.com/questions/497908/is-a-url-allowed-to-contain-a-space

On 16 June 2017 at 16:00, Eric E. Dolecki  wrote:

> I have deep linking working, but if I introduce spaces into the URL, it
> fails. Is this expected or can I do this another way?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Unicode filenames with Apple File System and UIManagedDocument

2017-03-21 Thread Aandi Inston
Is the question, what is canonical mapping? I'm going to assume it is, so I
can share what I found when I hit much the same issue. This is mostly from
memory so let's hope it's right.

Take the word Café. How many Unicode characters is this and what are they?
Turns out there are two answers. The last character as seen on screen is a
lower case e with an acute accent.
Let's ignore C,a,f as they are the same in all answers.  First answer: é is
'LATIN SMALL LETTER E WITH ACUTE' (U+00E9). We'll call this "composed". In
UTF-8 that's two bytes, 0xC3 0xA9. (This is the answer you'd often get, but
it's not the only answer, and not the one Apple filesystems like.)

Second answer uses an accent character. These are designed to appear in the
same space as another character. So combine "e" and an acute accent (like a
floating, slanted apostrophe) and we have "é". This means you could get the
same result from the two Unicode characters LATIN SMALL LETTER E (U+0065)
COMBINING ACUTE ACCENT (U+0301). We'll call this "decomposed". In UTF-8
that would be 0x65 0xCC 0x81: three bytes, two characters, combine to a
single character. (This is the one Apple filesystems like).

When you're typing in a word processor, or showing an alert, it hardly
matters how you create the e acute. Both look the same. But searching may
be a problem (not discussed) as may showing items in alphabetical order
(also not discussed).

Let's imagine now we have a filename Café. This could be represented in
UTF-8 bytes as 0x41 0x61 0x66 0xC3 0xA9 (composed), or as 0x41 0x61 0x66
0x65 0xCC 0x81 (decomposed). But ultimately there needs to be a set of bits
on disk, in a directory, saying the name of the file. When searching for a
file we could have three choices (a) these two composed/decomposed are
separate file names for two distinct files - whose name will look the same
(b) these are the same file, which means all file access by name, and
searching has to compose or decompose for comparison purposes (c) only one
is allowed and the other is rejected or invalid.

Where are we? A bit of (b) and a bit of (c). Finder and file dialogs always
decompose what is typed, and this is stored as the string of bits giving
the file name. It seems that some APIs will automatically decompose their
input, and others won't, and we may be in transition [to judge from the bug
response]. So for safety, use a method that decomposes. (Unicode define at
least two other types of de/composition, not discussed).

Apple calls decomposed "canonical". This is fine, except that Unicode
refers to both "canonical decomposition" (what Apple filenames need) and
 "canonical composition" (the opposite). So if handling names via an Apple
API made for filenames we are fine to talk of canonical file names. But if
handling names with a general Unicode API, we need to understand that this
means "canonical decomposition" rather than "canonical composition".

On 21 March 2017 at 11:03,  wrote:

>
> > What Apple suggested is to Unicode-normalize the filename before adding
> it to the URL. Did you try doing that?
>
> I’m trying to find out what that means.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: why use extern "C"

2017-03-07 Thread Aandi Inston
This is common practice. Here's why.  In C++ this

#ifdef __cplusplus
extern "C" {
#endif
………./*some function,struct*/

#ifdef __cplusplus
}
#endif

compiles as
extern "C" {
………./*some function,struct*/
}

As you identify, this declares C linkage, usually to a precompiled C
library, or to make a C-compatible library. The extern must be conditional,
because in pure C this form of extern is a syntax error.

So what happens in pure C? The #ifdef section is skipped because
__cplusplus is undefined. So it just compiles as
………./*some function,struct*/
In other words, just C definitions, which will have C linkage by default.

This allows a header file for a C library to be compiled in C, and to be
compiled in C++ with suitable linkage.

(You should not see // in this section, because in pure C it is forbidden).



On 7 March 2017 at 16:45, bigpig  wrote:

> I see some code like this in iOS project:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> ……….//some function,struct
>
>
> #ifdef __cplusplus
> }
> #endif
> if there is C++ compiler and use C linkage,but if there isn’t C++ compiler
> then use what?
> And what is the reason of using this way in code?
>
> Thanks!
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mystery Threads

2016-09-29 Thread Aandi Inston
My thoughts are general, not specific to Mac OS... The idea that the best
performance comes from threads = #CPUs is attractive, but will work only if
the threads do not sleep and do not interfere with each other. A classic
example is dividing up a complex calculation that runs without touching the
disk, reading large arrays, or sharing variables.

To construct a case where more than #CPUs might help, consider a thread
which sets up and reads from a network connection, then does something
trivial and repeats. If you have threads=#CPUs, each thread will start and
issue a network read. Then all the threads will wait for a reply and the
CPU is idle. More threads might help. But they might overwhelm the network,
so it might not be a good plan to have thousands. Exactly the same applies
if the thead reads or writes the disk. The thread might read the disk
deliberately, or it might get a page fault. More threads might help, but
the bottleneck is likely to be the disk, so the number of threads is almost
irrelevant.

Where threads run simultaneously on different CPUs, you want for best
performance to allow each CPU to work with data in its cache. Where one
thread writes a memory location that is read by another thread, the CPUs
are likely to have to flush their cache, and the multi-CPU performance
becomes that of an uncached CPU, which can be terrible. The hardware issues
here are complex and I haven't kept up with them; perhaps cache sharing has
improved.

On 29 September 2016 at 08:15, Gerriet M. Denkmann  wrote:

> I have a big array (like a few GB) which is operated upon by some
> functions.
> As these functions act purely local, an obvious idea is:
>
> - (void)someFunction
> {
> nbrOfThreads = ...
> sizeOfBigArray = ...  a few GB
> stride = sizeOfBigArray / nbrOfThreads
>
> dispatch_apply( nbrOfThreads, queue, ^void(size_t idx)
> {
> start = idx * stride
> end = start + stride
>
> index = start
> while ( index < end )
> {
> mask = ...
> bigArray[index] |= mask
> index += … something positive…
> }
> }
> )
> }
>
> As my computer has just 8 CPUs, I thought that using nbrOfThreads > 8
> would be silly: adding overhead without gaining anything.
>
> Turns out this is quite wrong. One function (called threadHappyFunction)
> works more than 10 times faster using nbrOfThreads = a few ten-thousand (as
> compared to nbrOfThreads = 8).
>
> This is nice, but I would like to know why can this happen.
>
> Another function does not like threads at all:
>
> - (void)threadShyFunction
> {
> nbrOfThreads = ...
> uint64_t *bigArrayAsLongs = (uint64_t *)bigArray
> sizeOfBigArrayInLongs = ...
> stride = sizeOfBigArrayInLongs / nbrOfThreads
>
> uint64_t *template = ...
> sizeOfTemplate = not more than a few dozen longs
>
> dispatch_apply( nbrOfThreads, queue, ^void(size_t idx)
> {
> start = idx * stride
> end = start + stride
>
> offset = start
>
> while ( offset + sizeOfTemplate < end )
> {
> for ( i = 0 ..< sizeOfTemplate )
> bigArrayAsLongs[offset + i] |= template[i]
> offset += sizeOfTemplate
> }
> }
> )
> }
>
> This works, but for nbrOfThreads > 1 it gets slower instead of faster. Up
> to hundred times slower for moderately big nbrOfThreads.
> This really bothers me.
> Why are the threads seemingly blocking each other?
> What is going on here?
> How can I investigate this?
>
> Gerriet.
>
> P.S. macOS 12, Xcode 8, ObjC or Swift.
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Emailing from a daemon process

2016-07-07 Thread Aandi Inston
> > Is there a way to fire off a simple email from an ObjC Foundation-only
app running in the background

"Just" sending email seems like such a simple thing. But remember, a Mac
doesn't come out of the box able to send mail. It only gets that ability if
it is set up to do so (during initialisation, or later in a mail app). This
setup will include an SMTP server, and may well include personal login
information to that server. Macs do not (unless I missed it: would be
useful) set up a generic configuration that can be used to send mail.

So, if it is set up you would have to either interface with the email app
(if you know what it is), or read and use the preferences of the app (if
they are usable, and you'd rather hope security info wasn't).

Bear in mind too, that the user may not set up any email app, so there is
nothing to build on at all. I don't have any need to send email on most
Macs, so I don't set it up at all. On others, I use webmail like millions
of others; again, nothing to tap into, and the webmail service might not
even offer SMTP.

Now, if you are in a position to do so you can ask your user to set up
mail: you need an SMTP server, an optional port, and perhaps to support
security options securely (keychain?) Sending non-secure email to SMTP is
the absolutely trivial part (unless you want attachments). Bear in mind
many users will not have an SMTP server they can even give you and may be
stuck.

Lastly, sending SMTP traffic to port 25 is exactly the sort of thing that
malware does, so you are likely to hit blocks now or in the future.

Sorry if this is repeating points already made.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

unicode fraction symbol in a NSTextView

2016-06-22 Thread Aandi Inston
Almost certainly not the font itself. Looks like classic mojibake. The
sequence which you seem to report, capital A circumflex, one-half might be
in the encoding ISO-8859-1 (aka Windows-1252 aka informally Latin1).

If so we have
c2 - capital A circumflex
bd - one half

But what is the UTF-8 form of one-half? It is c2bd.  So this seems the
classic case of interpreting UTF-8 as ISO-8859-1. Where that is happening
is for you to find, but my bet is that it is later than you think.

On 22 June 2016 at 17:32, tridiak > wrote:

> I am setting some text to a NSTextView which includes the ‘½’ character.
>
> s = name + “ CR "
> switch (CR) {
> case 0.5:
> s=s+”½” // \u{00bd}
> ...
> let d : NSData = s.dataUsingEncoding(NSUTF8StringEncoding)!
> let ats : NSMutableAttributedString = NSMutableAttributedString(HTML: d,
> documentAttributes: nil)!
> self.blab.textStorage?.setAttributedString(ats)
>
> What I see is 'Aasimar CR ½’ instead of 'Aasimar CR ½’.
> Where is the ‘Â' coming from?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: DNS resolution for apps vs Terminal?

2016-06-14 Thread Aandi Inston
Really facbook.com ? If so, maybe it's some kind of protection, the site is
owned by MarkMonitor; perhaps there is a blocker on these things.

On 14 June 2016 at 10:11, Rick Mann  wrote:

> Just now Safari stopped being able to load facbook.com. So did Chrome.
> Both reported DNS failures.
>
> But dig on the command line, and curl, both succeed.
>
> How are these two domains different?
>
> --
> Rick Mann
> rm...@latencyzero.com
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: PDF image template comes out too small

2016-06-01 Thread Aandi Inston
I've never used this API but perhaps the problem is that you are thinking
of PDF pages as having a size in pixels. They absolutely do not, because
they are a rich collection of text, multiresolution images and vector. The
fact that your PDF pages might contain only a single resolution image is of
no importance (yes, none). PDF files do not have a DPI even if tools claim
they do. They DO have a real size in inches/mm. Clearly when painting a PDF
on screen an API will ASSUME a resolution to map to screen pixels, based on
the size in inches/mm only, since monitor inches aren't real.

A further complication is that each page may have multiple boxes. An API
might use the media, crop, art or trim box for size in inches/mm with a
default for missing boxes.

So there is much more to be concerned with than when using a bitmap format.

On Wednesday, 1 June 2016, David Catmull  wrote:

> I'm trying to use PDF files as image templates for my segment controls, but
> they come out too small.
>
> I created them using Affinity Designer, adding the "Template" suffix. They
> end up getting drawn at half size in my controls. I tried changing the
> export DPI from the default (~144) to 72, but it had no effect.
>
> Exporting them as png instead works fine - at runtime, that is. Xcode
> 7.3.1's editor shows them at half size like the PDFs. This only happens
> with my custom images, never with standard system images.
>
> The images are 16x16, exported using Designer's "PDF (flatten)" setting. My
> segment control is "small square" style, with 37px wide segments.
>
> How can I make them display at the right size? I can make do with pngs if
> necessary, but for one thing I like not having to have @2x versions of
> everything. Plus Apple's documentation recommends PDF for template images,
> so it ought to work.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com )
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

32-bit / 64-bit roadmap

2016-01-21 Thread Aandi Inston
So far as I can see, all recent Mac OS systems are 64-bit on 64-bit
hardware and can run an app shipped in 64-bit only. And 32-bit continues to
run fine.

But what about the future? Perhaps we can only speculate about whether
32-bit apps will be deprecated, but maybe Apple have started to hint that
32-bit has a limited lifetime? It's a question of prioritising work on old
apps, and what will happen to our customers with older apps in future.
Let's assume Cocoa has been weeded out of the apps already.

Thanks in advance for your speculations (or more solid facts!)
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re:

2016-01-19 Thread Aandi Inston
Thank you. The problem turned out to be a foolish mistake in the caller,
but this has alerted me to the need for a systematic check of the
conversion between BOOL and C integers.

On 19 January 2016 at 17:15, Jake Petroules 
wrote:

Note that BOOL is a typedef for signed char in the legacy (32-bit OS X)
> runtime, and a typedef for bool in the modern (64-bit OS X, iOS, tvOS,
> watchOS) runtime. You should use `return !!ok` or `return ok != NO` to
> force boolean coercion.
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

[no subject]

2016-01-19 Thread Aandi Inston
I have this handy routine:

int MacNSOpenFileWithDefaultApp ( char *path )
{
NSString *nsstring = [NSString stringWithUTF8String: path] ;
BOOL ok = [[NSWorkspace sharedWorkspace] openFile:nsstring] ;
return ok ;
}

Suppose we pass a folder name. The intention is to open the folder in the
Finder.

When the app is compiled as 32-bit and run on Mac OS 10.10.5, it opens the
folder
and returns 1.

But when the app is compiled as 64-bit and run on the same system, it still
opens the folder but returns 0.

Any ideas? Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Bitmaps, colorspaces, etc.

2015-12-21 Thread Aandi Inston
I don't know anything about these methods. But in colour space work,
"retagging" would usually mean changing the attached colour profile without
changing the pixel values.

For example, if an image starts as AppleRGB, it could be tagged as sRGB.
This is not a conversion. The pixel values, numbers, are unchanged. So the
meaning of the pixel values, now interpreted as sRGB rather than AppleRGB,
would change, and the colour would shift. At a push "retagging" an untagged
image would give a specific meaning to the pixels rather than a
default/device dependent meaning.

So (pure speculation) maybe creating as CalRGB would create it with some
unknown/default profile and you can later tag it. That would imply that the
main job of colorSpaceName is to deliver information on the number of
components, rather than how to colour map.

On 21 December 2015 at 01:15, Graham Cox  wrote:

> I’m trying to understand how properly to use colorspaces with bitmaps.
>
> In my app’s Export function, we’d like to offer the ability to choose a
> colorspace for the exported image, in whatever format the user chose. My
> thoughts were to use NSBitmapImageRep to capture the image, then use its
> -representationUsingType:properties: method to get the image data in
> whatever format before writing it to disk. So far so good.
>
> NSBitmapImageRep accepts a ‘colorspaceName’ parameter when it’s created,
> and these can be one of the following:
>
> • NSCalibratedWhiteColorSpace
> • NSCalibratedBlackColorSpace
> • NSCalibratedRGBColorSpace
> • NSDeviceWhiteColorSpace
> • NSDeviceBlackColorSpace
> • NSDeviceRGBColorSpace
> • NSDeviceCMYKColorSpace
> • NSNamedColorSpace
> • NSCustomColorSpace
>
> Which are all strings, and seem to represent a very generic non-specific
> kind of colorspace.
>
> These don’t match with the colorspaces known to the system as returned by
> +[NSColorSpace availableColorSpacesWithModel:], which returns an array of
> NSColorSpace objects, each of which is able to return a -localizedName
> property, which are very specific, and do not relate to the above names at
> all.
>
> How do I bridge this impedance mismatch? If the user wants to Export using
> a specific, named colorspace, as chosen for example from a list of the
> colorspaces returned by the +availableColorSpaces method, how should I go
> about creating the appropriate bitmap? I see that NSBitmapImageRep has
> methods such as -bitmapImageRepByRetaggingWithColorspace: and
> -bitmapImageRepByConvertingToColorSpace:renderingIntent:
>
> What does ‘retagging’ mean? Presumably converting duplicates the bitmap,
> so could be a memory strain. This seems unnecessary if I could create the
> bitmap with a specific colorspace in the first place.
>
> Also, when creating a bitmap, what does using ‘NSNamedColorspace’ do?
> Which named colorspace? What about ‘NSCustomColorSpace’? These seem only to
> indicate what general kind of colorspace to expect, not a specific one.
>
> The problem here is that I can find no documentation that goes anywhere
> near explaining this. Maybe NSBitmapImageRep is too high level and I need
> to drop down to CGImageRef? That class does seem to take a specific
> CGColorSpace object, though how I get there from +[NSColorSpace
> availableColorSpecs] is unclear.
>
> Am I even asking sensible questions? This sort of impedance mismatch
> usually suggests a conceptual misunderstanding somewhere, but without a
> clear explanation of how colorspaces and bitmaps are used, I can’t see
> where I may have gone wrong.
>
> Anyone able to illuminate?
>
> —Graham
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>
> This email sent to aa...@quite.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Translating offset from crash dump

2015-12-19 Thread Aandi Inston
This seems tangential to cocoa-dev, though I am in a callback from a Cocoa
method, I don't think the crash is inside Cocoa but my own code. But here's
the problem, maybe someone can suggest a better forum.

I have a crash dump from a customer. I cannot reproduce the problem, and I
cannot expect the customer to have endless patience to run test versions
etc. The crash dump identifies the crash location as Routine+offset as I
would expect. The problem is determining the source line corresponding to
this (I realise that, due to optimization, the question of source line is a
fuzzy one, but some clues would help).

I have found how to view the assembly code in xcode 6, but there are no
offsets. I cannot use the as command on this assembly code because it seems
to use a lot of pseudo-ops not understood by as (I don't know if as would
give a report anyway). I could hand assemble but I don't know the
pseudo-ops either. otool doesn't seem obviously to help. Running the debug
version in the debugger won't give accurate offsets. I suspect my best bet
might be to load the production product (complication: it is a plug-in, not
an app), in the debugger, and examine the routine code, perhaps comparing
to the assembly code, but I don't know how to use gdb that way.

Anyway, what would you do with a crash dump routine + offset, not
reproducible?
Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Drawing many different strings quickly

2015-09-28 Thread Aandi Inston
I'd like to suggest a different approach if things cannot be tuned to have
far fewer draw calls. Font caching etc. is very fast, but not as fast as it
could be given the choices it has to support. I think you said you had one
font, one size. I'm guessing you also have no more than 256 different
characters you might show (but consider where in the world your customers
are...)

If so, perhaps you could simply have a table of 256 images, and paint them
to screen in the fastest possible way. Now, that's a lot of code to write
speculatively, but you can see if it will save time by replacing every
paint text call with a call to paint a single fixed image. If it goes fast
enough it may be worth this approach. (I'm sure there are fast and slow
ways to paint images too: grid aligned, unscaled, colour model matching -
maybe some of these can be optimized. Monochrome mask painting might be
faster, or slower).
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Localised alert/confirm message

2015-09-22 Thread Aandi Inston
I use NSAlert to display a dialog with OK/Cancel, and noticed this had
(wrongly) not been localized in my code. However, I noticed some other
things. From the spec, if I replace OK/Cancel with other text, the
automatic assignment of keyboard shortcuts is not done. All of this can be
fixed, but I'm wondering if there is an approved method which would display
a dialog with text, OK, or OK/Cancel localized to the current locale.

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Edit menu localisation, default application menu

2015-07-11 Thread Aandi Inston
It turns out, and I'm sure this will surprise nobody but me, that for the
copy/paste/cut keyboard commands to work in Cocoa my app needs to have a
suitable Edit menu with copy/paste/cut menu items and keyboard equivalents.
My question is about localisation. The app is localised via its own string
files. Clearly I can add Edit/Copy/Cut/Paste to the strings for
translation.

But is there a better way to display a suitable Edit menu and use the
locale standard translation for these names?

Related: I observe that, even if I replace the [application mainMenu], that
the menu which is then displayed has fixed, and localised, entries under
the app name. That the title of the first menu is ignored and the contents
merged with the standard ones. Old news I'm sure, but I can't find where
this behaviour is documented, and what surprises it may have. Sometimes a
quit and leave Windows or similar item appears, for instance. Can anyone
point out what I should be reading?

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

First responder (?) problem, and orphaned highlight boxes

2015-04-15 Thread Aandi Inston
I am trying to solve a problem which seems to involve the first responder
for an NSWindow.

The NSWindow contains a number of controls and views, including several
NSTextField controls.
It is necessary to show or hide groups of these. These are all created
dynamically, rather
than with Interface Builder.

When a field containing text (created as an NSTextField) is contains the
cursor, it has
a blue(?) highlight box drawn around it. (We do not implement this, it just
happens). But
when the field is hidden, we would like the highlight box to go away.

In our oldest test system, 10.6.8, this is what happens - the highlight box
is removed when
the text field is hidden. But in our newest available test system, 10.10.1,
the highlight box
is left in place, only moving if we click into one of the newly shown
NSTextFields.

So, it seems reasonable to check, when hiding a field, whether it is
highlighted. This is
where I'm stuck. I use [NSWindow currentFirstResponder], but the value
returned is never
the NSTextView that I am hiding. It seems to be an NSText object, which I
didn't make.
Perhaps it is the [NSTextField currentEditor]. But this is getting into
guesswork. So...

1. Is there a more appropriate way to identify if a particular control has
what I would
loosely call the focus?
2. As a quick fix, is there a way to make sure this highlight box
disappears with the
control that it is (to my mind) attached to?

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Painting standard check box/radio button mark

2015-04-09 Thread Aandi Inston
Is there a way to paint a standard check box or radio button mark, in its
various states? I am implementing a custom control which would benefit from
this. Clearly one could define a textless NSButton within one's own
control, but I was wondering if there is a stock image repository for
such things, and I worry about the NSButton taking away the clicks I want
to see.

Thanks in advance!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSButton (radio button) not calling action when overlapped by invisible NSButton?

2015-03-13 Thread Aandi Inston
(This is odd. I did not receive a copy of my post and therefore assumed it
had not posted. Clearly it did as you were kind enough to reply)

Happily I found the solution. This list earlier helped me to understand a
problem which appeared in recent Mac OS, where radio buttons would all work
as an automatic group (clicking one would turn off all the others), which
is a pity if one wanted multiple groups.

This turned out to be a new feature of Mac OS likely to affect other
control libraries; triggered when a number of conditions were met including
having the same actions. Which, since these are generated by a control
library, they all had. The solution to THAT issue was to wrap each radio
button in its own parent NSView, and place the NSView in the dialog rather
than the radio button. Of course this requires managing two controls: the
NSView (e.g. for moving the control) and the NSButton (e.g. for checking
the button).

The problem was that HIDING the control was still being applied to the
NSButton. The NSView was remaining visible (though having no visual
aspect) and intercepting clicks if it happened to be on top. The solution
is of course to hide the NSView instead of the NSButton.

Converting to an NSTabView would be difficult because the higher level
control library manages visibility and expects to be able to do so at the
level of individual controls. But it may be prudent to always disable
NSControl based controls when they are hidden.

Hope this helps anyone who finds a similar issue.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSButton (radio button) not calling action when overlapped by invisible NSButton?

2015-03-10 Thread Aandi Inston
I am implementing the Cocoa back end of a portable control library, and
have hit one particular strange problem.

The dialogs are frequently very complex, with areas showing different
groups of controls according to context. Individual controls are
shown/hidden by the higher level code to make this work. Radio buttons are
naturally implemented as an NSButton with suitable style.

I have just one dialog where some of the radio buttons are dead. It seems
that the action callback, set with setAction: is not called some of the
time.

Initial studies suggest that this happens when a later radio button
(another NSButton, or rather the same descendent of NSButton) occupies the
same space. This later button is hidden (setHidden:true), but seems to be
somehow stopping the click getting to the rear control.

Tested:
- The front, invisible, control is not receiving an action callback either
- Disabling (setEnabled:false) the hidden control does not change anything

Can anyone make any suggestions about whether this diagnosis has any ring
of truth, and how to fix or further investigate it?

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSWorkSpace performFileOperation (a)synchronousness

2015-03-05 Thread Aandi Inston
 have a requirement to copy files from my Mac OS app. I find:
success=[NSWorkSpace performFileOperation:NSWorkSpaceCopyOperation
 source:nsstring*  // source directory path
 destination:nsstring* // target directory path
 file:nsarray* // nsstring array containing short paths of files or
directories
 tag:nsinteger* // on return, 0 on failure, 0 if sync finish, 0 if async
]
My question relates to asynchronousness (is that a word)? It looks like a
synchronous method as it returns a success or failure. But the documentation
says of the tag variable a positive integer if the operation was performed
asynchronously. If the value is a positive integer, the value is a tag that
identifies the requested file operation. This confuses me. The examples
I've
seen don't do anything special with the tag.

I may be just missing a document giving a context to this...

Its in the past tense.  If it said has been started asynchronously of
course I
would be looking for a method to wait for completion.

So what does was performed asychronously mean?
Do I need to care? In what sense was it asynchronous if my API is waiting
for completion? What is the requested file operation identifier and what API
might I use it with? Do I need to release it?

Thanks in advance
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Am I Reinventing the Wheel? (Part I)

2015-01-08 Thread Aandi Inston
I am not familiar with the API you are using, I use my own XML
generator/parser, but it may be worth nothing something about XML. XML
files are implicitly Unicode and generally UTF-8. So you cannot put an
arbitrary sequence of bytes into XML as a string. A curly quote is not in
the low Latin (=127) range so it must be a multibyte value.

Clearly there are different API approaches possible on encoding:
- convert an input encoding to UTF-8
- accept and write UTF-8 with validation, rejecting bad UTF-8 sequences
- accept and write UTF-8 with validation, converting bad UTF-8  sequences
silently to something else
- accept and write UTF-8 without validation, potentially writing malformed
XML
Parsers have similar choices to make. But anyway, if your data is not valid
UTF-8, it would explain why you get disastrous results.

XML has no standard binary representation for anything other than Unicode
strings, so symmetric encoding/decoding of such data, following your own
invention or some extension to basic XML, is the only way. A low level XML
API cannot be expected to offer this, especially one intended to write XML
for consumption by other software.

(This is in addition to the five characters prohibited in strings because
they are XML markup).


On Thu, Jan 8, 2015 at 12:43 PM, Charles Jenkins cejw...@gmail.com wrote:


 I'm writing data to XML. When you create a node and set its string
 contents, the node will happily accept whatever string you give and allow
 you to serialize information XML deserialization cannot then recreate. In
 my case, the string in question contained curled quotes. I could serialize
 and save the data—and if I remember correctly* the output looked good when
 I inspected the file on disk—but reading it back and deserializing it led
 to disaster! Right now I'm using NSString stringByAddingPercentEncoding:
 and having no further problems with curled quotes, but I'm sure that's a
 poor long-term solution.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Kerning Pairs

2014-10-13 Thread Aandi Inston

  It sounds like you're trying rrreay hard to avoid admitting to
  yourself that your model code needs to be rewritten.

 I don't think so as our model code works just fine when driven from
 Windows V-C that get a font, gets it its outline and mer table and call the
 model.  Beautiful output.


Maybe you are both right. See
http://www.microsoft.com/typography/otspec/kern.htm
NOTE: Apple has extended the definition of the 'kern' table to provide
additional functionality. The Apple extensions are not supported on
Windows. Fonts intended for cross-platform use or for the Windows platform
in general should conform to the 'kern' table format specified here.

So the chances are most fonts for general consumption (but not necessarily
those from Apple) will have the older format even if they have the new one.
You may be rubbish results for Apple fonts, in which case the new Apple
table 'kerx' becomes relevant. You can support both.

Kerx might give better results but that is a trap in itself if you want
cross-platform consistency; your needs might be for consistent layout cross
platform rather than better kerning on one platform. Only you can know this.



 Is it possible to get the 'kern' table if it exists?


In CTFont Reference see Getting Font Table Data. Be particularly careful
of endianness.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Why not use path-based API? (was: Loading image resources)

2014-09-14 Thread Aandi Inston
 No one should be using path-based API any more, generally.
 You should use URL-based equivalents.

Why? Really, why? Certainly there are APIs where we have to use URL's and
we have to convert the path into a URL, but where a non-deprecated
path-based URL exists, what current or future obstacles do you foresee? The
URL doesn't seem to be more predicable or persistent, for example.

Thanks for any insight. I've been really happy to see the last of the
old-style colon-separated names and move to something I can understand, a
pathname.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSButton radio buttons, automatic grouping

2014-08-29 Thread Aandi Inston
I'm running the same code in 32-bit and 64-bit, and seeing a difference I
cannot currently account for. The code is an implementation of a widget
library, specifically the bit dealing with radio buttons.

The radio buttons are created as NSButton instances with a buttonType of
NSRadioButton. The library presumes buttons are independent of one another
and manages its own grouping, so that a click on one button clears the
other buttons in the same group. There are many dialog boxes with multiple
groups of radio boxes.

So, this all works as expected in 32-bit. In 64-bit mode, clicking on any
one of the radio buttons clears all the others in the NSWindow (without
regard to our own logical grouping). Initial tests suggest our code is not
doing that.

Now, I see references to radio button groups in an NSMatrix as being
automatically linked, but I am not using an NSMatrix, and I can't see any
methods of NSButton or NSButtonCell related to this. All the NSButton
controls are placed in the same NSWindow (whether in 32-bit or 64-bit mode).

Thanks for any insight!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Transparent NSImage in NSButton

2014-08-19 Thread Aandi Inston
I'm wondering what the right way is to use transparent images in an
NSButton (not using Interface Builder as this is a port of a platform
independent dialog library, which is also required to work back to 10.5).
Transparent images here = PDF loaded as NSImage which do not paint their
entire canvas.

These NSButton elements sit in an NSWindow with default background Color.
The problems:
- sometimes (as yet unclear when but it might have started when we started
to set image scaling) the first paint of the image has a
white background.
- subsequent repaints (e.g. when the button is clicked) repaint on the
window's background, i.e. seemingly as required
- each subsequent repaint does not clear the background. This results in
repeated clicks making the image darker and darker, or if there is an
alternate image we are left with the shadow of both.

Key definitions
- NSButton setImagePosition:NSImageOnly setBordered:no and
[[button cell] setImageScaling:NSImageScaleProportionallyUpOrDown]
- For a single image, NSButton setImageType:NSMomentaryLightButton
- For two image, NSButton setImageType:NSToggleButton or
NSMomentaryChangeButton

I'm wondering if I need to add code that causes the button area to be
erased or repainted in the background colour before it is painted. Or
perhaps use a different control/view type altogether (NSImageView?) and
mandate non-transparent images where button functionality is actually
needed.

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Aligning baseline of NS controls

2014-07-10 Thread Aandi Inston
I am porting a library for dynamic dialog creation to Cocoa.
The implementation is using various standard controls such as
NSTextField and NSButton. I have a question.

Suppose a dialog is to contain a line with multiple controls like

[ ] Add  seconds [before/after]

Here
[ ] Add  is a check box
_  is an editable text field
seconds  is a noneditable text field
[before/after]  is a popup button

Each of these controls contains text, and the aim here is to align the text
so it does not jump up and down - to align the text baseline. If the top of
the controls, or the bottom of the controls, are aligned then the text
itself will not be aligned.

Two possibilities suggest themselves
- fixed constants, based on experiments (which will perhaps go awry if the
system configuration changes)
- work out the height of each of these controls, assume padding is equal
top and bottom, and adjust alignment by half of the difference (this is an
attractive idea, but I note in a single experiment that the height of
noneditable text was 16 while editable text was 21, a difference of 2.5
pixels which is awkward).

Is there a better way to do this? I imagine it's a problem faced before.

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com