Re: Accessibility Settings

2024-01-11 Thread Keary Suska via Cocoa-dev
I don’t have those settings on my Mac (Monterey) so I can’t check but I wonder 
if you can simply query existing controls for their font information?

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Jan 11, 2024, at 8:50 AM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> I’m sure there is an easier way to do this but well, I don’t know what it is.
> 
> In the System Settings: Accessibility: Display: Text, I set my font size to 
> 13.
> 
> There is a database is located at /Library/Application 
> Support/com.apple.TCC/TCC.db . To query the database from the command line, 
> use sqlite3 or an SQL browser (I used DB Browser).
> 
> The modification date of that file does not reflect that it was just modified 
> and there is no 13 in it. (I copied the file to another directory to view)
> 
> In the file in the access table, I found entries for many of the app bundle 
> identifiers, but nothing for text and nothing with a 13 in it.
> 
> Ideally I’d search the entire drive for a mod date of today and locate that 
> file, but I’ll leave that up to you.
> 
> Good luck.  Let us know what you find.
> 
> Cheers,
> Alex Zavatone
> 
> 
> 
>> On Jan 11, 2024, at 10:58 AM, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> I had to do something like that on iOS a few years back.  Let me see if I 
>> have a solution for MacOS.
>> 
>> Cheers, 
>> Alex Zavatone
>> 
>>> On Jan 10, 2024, at 10:48 AM, Tom Doan via Cocoa-dev 
>>>  wrote:
>>> 
>>> I'm trying to figure out how to query the value for the 
>>> Accessibility---Display---Text Size for MacOS (Objective-C). I can't 
>>> for the life of me find any documentation on it, and anything that 
>>> looks even close appears to be for iOS and Swift. Can anyone point 
>>> me in the right direction?
>>> 
>>> Best regards,
>>> 
>>> Tom Doan
>>> ---
>>> Estima
>>> 2717 Harrison St
>>> Evanston, IL 60201
>>> USA
>>> 
>>> 
>>> ___
>>> 
>>> 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/zav%40mac.com
>>> 
>>> This email sent to z...@mac.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/zav%40mac.com
>> 
>> This email sent to z...@mac.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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 interference with AirPlay

2022-06-15 Thread Keary Suska via Cocoa-dev
A more useful response may be that you may already have devices that support 
AirPlay. By any chance have you checked to see if any devices show under the 
AirPlay menu in the Music desktop app? Note that Mac computers can AirPlay to 
each other. Many smart TV’s support AirPlay, as do most modern Internet-enabled 
receivers. Also note that devices might need to be turned on to be found.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Jun 15, 2022, at 7:26 AM, Steven Mills via Cocoa-dev 
>  wrote:
> 
> On Jun 15, 2022, at 03:44:41, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
>> Making matters worse, I don't have AirPlay.
> 
> Everybody has Airplay. It's a feature, not a thing.
> 
> --
> Steve Mills
> Drummer, Mac geek
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Problem with rangeOfString and Umlauts

2022-03-11 Thread Keary Suska via Cocoa-dev
NSRange is 0-based, so the 16th character is index 15. Also you might want to 
use -localizedStandardRangeOfString: instead...

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Mar 11, 2022, at 9:10 AM, Jack Brindle via Cocoa-dev 
>  wrote:
> 
> I just placed your code into a short tool in Xcode. What I get is interesting:
> 
> prefix_lenunsigned int15
> 
> Which his as you say. But:
> 
> space_in_filename NSRange location=15, length=1   
> 
> Which is not the same as you say. This is in Xcode 13.2.1. Is something else 
> going on?
> 
> For the record, the body of main contains:
> 
>   @autoreleasepool {
> 
>   NSString *file_basename = @"Morgendämmerung (1)";
>   NSString *info_item = @"Morgendämmerung";
> 
>   NSString * prefix = [info_item commonPrefixWithString: 
> file_basename options: NSCaseInsensitiveSearch ];
>   unsigned int prefix_len = (unsigned int) [prefix length];
> 
>   NSRange space_in_filename = [file_basename rangeOfString: @" " 
> options: 
> NSDiacriticInsensitiveSearch|NSCaseInsensitiveSearch|NSWidthInsensitiveSearch];
> 
>   NSLog(@"Break heere");
>   }
> 
> So what is different?
> 
> Jack
> 
> 
>> On Mar 11, 2022, at 11:17 AM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> 
>> Well, SSIA.
>> In more detail, I've got two strings:
>> 
>> file_basename = @"Morgendämmerung (1)"
>> info_item = @"Morgendämmerung"
>> 
>> This code
>> 
>>   NSString * prefix = [ info_item commonPrefixWithString: file_basename 
>> options: NSCaseInsensitiveSearch ];
>>   unsigned int prefix_len = (unsigned int) [prefix length];
>> 
>> yields prefix_len = 15
>> as it should.
>> 
>> The problem arises with this line of code:
>> 
>>   NSRange space_in_filename = [file_basename rangeOfString: @" " options: 
>> NSDiacriticInsensitiveSearch|NSCaseInsensitiveSearch|NSWidthInsensitiveSearch];
>> 
>> which yields space_in_filename.location = 16 !
>> 
>> This thwarts the rest of the code, which, in this case, would expect 
>> space_in_filename.location = 15.
>> 
>> Needless to say that with strings that do not contain Umlauts, the call of 
>> rangeOfString:options: works as expected, i.e., in the above example 
>> space_in_filename.location is as expected (i.e., first character has 
>> location=0).
>> 
>> I have also tried localizedStandardRangeOfString, with the same effect.
>> 
>> Any ideas what I can do?
>> 
>> 
>> 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/jackbrindle%40me.com
>> 
>> This email sent to jackbrin...@me.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Indexing broken for one project

2022-02-06 Thread Keary Suska via Cocoa-dev
I have come across issues where a code syntax error messes up indexing—are you 
able to do a full, successful compilation? Other than that, I have heard that 
some issues might require a system restart, i.e. 1) quitting Xcode; 2) deleting 
derived data (if you use a shared location you might also want to delete or 
move derived data from other projects); and 3) restarting the computer.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Feb 6, 2022, at 9:32 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Thanks a lot for your response.
> 
> I had tried that already, to no avail.
> 
> I am seeing lots of   "Crash detected during compilation"
> in Xcode's indexing log.
> 
> Best regards, Gabriel
> 
> 
> 
>> On 6. Feb 2022, at 19:18, Rob Petrovec  wrote:
>> 
>> Quit Xcode, delete the DerivedData directory for your project and re-open 
>> your project.  That should trigger a re-index and a full rebuild of your 
>> product.
>> 
>> The default location for the DerivedData directory is in 
>> ~/Library/Developer/Xcode/DerivedData/-> letters>.  You can also configure it to be in your source directory, like I 
>> do, so you can keep your build products with your code.
>> 
>> Hope that helps.
>> 
>> —Rob
>> 
>> 
>>> On Feb 6, 2022, at 6:20 AM, Gabriel Zachmann via Cocoa-dev 
>>>  wrote:
>>> 
>>> A few weeks ago, indexing in Xcode 13 stopped working for one of my 
>>> projects.
>>> So, for instance, "Jump to Definition" does not work any more.
>>> I don't know what stopped indexing to work.
>>> 
>>> The project consists of objective-c source code.
>>> For other projects, indexing still works fine.
>>> 
>>> I have tried to delete Derived Data (which, in my case, is stored under 
>>> /tmp).
>>> I have also tried to follow these instructions 
>>> https://levelup.gitconnected.com/uncovering-xcode-indexing-8b3f3ff82551
>>> and perused the log file, but I could not see any error messages.
>>> 
>>> Any ideas what else I can try?
>>> Could it be something in the source code / header files?
>>> (The project compiles just fine, though.)
>>> 
>>> 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/petrock%40mac.com
>>> 
>>> This email sent to petr...@mac.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Intermittent invisible NSWindow

2021-11-15 Thread Keary Suska via Cocoa-dev
I can say it has been true in the past, even if it is no longer the case. It is 
not something I test with each OS release. I certainly can move a window almost 
entirely offscreen—enough to not notice it at least. Also, your suggestion that 
the window may have an invalid size could also be the case, additionally 
revealed by logging the window frame. I have seen some auto layout wonkiness 
that forces  too-small frame, though not enough to  make it disappear. 

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Nov 15, 2021, at 7:13 AM, Tom Doan via Cocoa-dev 
>  wrote:
> 
> Thanks, but is that true? I've tried forcing the window off screen with 
> setFrame: and it still shows up (generally pinned to the top of the 
> visible frame) even though the [NSWindow frame] returns the 
> "off-screen" location that I programmed in. The only way I have 
> found to make the window "invisible" is to give it a non-positive size, 
> and then pulling it off the window menu still won't show it.
> 
>> Have you logged the window coordinates? It might be placed fully
>> offscreen, and that would produce the behavior you are seeing.
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>> 
>> 
>>> On Nov 13, 2021, at 9:52 AM, Tom Doan via Cocoa-dev
>>>  wrote:
>>> 
>>> I'm having a problem with an application where a small percentage of
>>> users have one particular NSWindow type which doesn't show even
>>> though it goes through a makeKeyAndOrderFront. It's on the window
>>> list and will open if they do a tile, cascade or window switch
>>> operation, but doesn't come up initially. I can't reproduce this on
>>> any of my computers running three different flavors of MacOS
>>> (including Big Sur and Monterey). What should I be looking for that
>>> might cause this behavior.
>>> 
>>> Best regards,
>>> 
>>> Tom Doan
>>> ---
>>> 2717 Harrison St
>>> Evanston, IL 60201
>>> USA
>>> 
>>> 
>>> ___
>>> 
>>> 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/cocoa-dev%40esoter
>>> itech.com
>>> 
>>> This email sent to cocoa-...@esoteritech.com
>> 
> 
> 
> ---
> 2717 Harrison St
> Evanston, IL 60201
> USA
> 
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Intermittent invisible NSWindow

2021-11-13 Thread Keary Suska via Cocoa-dev
Have you logged the window coordinates? It might be placed fully offscreen, and 
that would produce the behavior you are seeing.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Nov 13, 2021, at 9:52 AM, Tom Doan via Cocoa-dev 
>  wrote:
> 
> I'm having a problem with an application where a small percentage 
> of users have one particular NSWindow type which doesn't show 
> even though it goes through a makeKeyAndOrderFront. It's on the 
> window list and will open if they do a tile, cascade or window switch 
> operation, but doesn't come up initially. I can't reproduce this on any 
> of my computers running three different flavors of MacOS (including 
> Big Sur and Monterey). What should I be looking for that might 
> cause this behavior.
> 
> Best regards,
> 
> Tom Doan
> ---
> 2717 Harrison St
> Evanston, IL 60201
> USA
> 
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Accessing a property of a view via its controller doesn't work

2021-09-04 Thread Keary Suska via Cocoa-dev
Perhaps a more germane question might be, are you sure that the view controller 
has a relationship with any window? It is not necessary, as I understand, for a 
view to exist in a window. A view controller can load a view without placing it 
into a window, and therefore viewWillMoveToWindow: will not be called, and I 
suspect the “window” property would be set. Breakpoints are your friend.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Sep 4, 2021, at 12:06 PM, Ben Kennedy via Cocoa-dev 
>  wrote:
> 
> 
>> On Sep 4, 2021, at 10:27 AM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> I access the window of a view by two different ways, in the controller and 
>> in the view, resp., and in the controller, I always get a nil pointer.
>> 
>> In my app, I have a subclass of NSView, MyView, declared like this:
>> 
>> @interface MyView : NSView > CAAnimationDelegate>
>> {
>>   NSWindow * window_;
>>   ...
>> }
>> @property (readwrite) NSWindow * window_;
> 
> What’s the purpose of this? NSView already has a `window` property that 
> returns its parent window. Why not just use that?
> 
> -ben
> 
> Sent from my iPhone
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Special question about NSOpenPanel

2021-05-24 Thread Keary Suska via Cocoa-dev
I don’t know if this helps but I have noticed issues under Catalina where with 
various applications that the save panel simply and inexplicably fails to open. 
I haven’t thought to see if the open panel was not working either but since 
it’s a subclass the issues could be related. There doesn’t seem to be any rhyme 
or reason and it happens just as much if not more with Apple apps (Safari & 
Preview especially) as well as others. I suspect a bug in the OS.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 24, 2021, at 12:55 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have a special situation where NSOpenPanel does not open a panel.
> 
> The circumstances:
> My app is actually a screensaver, so it's run inside legacyScreenSaver.
> Also, it seems to occur only under macOS 10.15.0, and (perhaps) only for some 
> users, not all.
> 
> What happens is that [oPanel runModal] does not open the panel, but I know 
> from the messages my screensaver saves in the log that it does get executed.
> Instead, it seems to return directly/immediately with return code 
> NSModalResponseCancel.
> 
> Below is the relevant source code.
> 
> Question: does anyone have an idea what might be causing this strange 
> behavior?
> 
> (It goes without saying that on my system everything runs fine, both on macOS 
> 10.15.4 and macOS 11.3.1.)
> 
> Thanks a lot in advance.
> 
> Best regards, Gab.
> 
> 
> Source code:
> 
>NSOpenPanel *oPanel = [NSOpenPanel openPanel];
>[oPanel setAllowsMultipleSelection: NO];
>[oPanel setCanChooseDirectories: YES];
>[oPanel setCanChooseFiles: NO];
>long int result = [oPanel runModal];
>new_url = oPanel.URL;
> 
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: MacOS: nonmodal NSAlert panel

2021-05-12 Thread Keary Suska via Cocoa-dev
I believe Apple uses NSPopOver for non-modal alerts and dialogs, which can 
automatically dismiss when the user clicks outside the popover.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 12, 2021, at 12:17 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> I had thought it was possible on MacOS to run an NSAlert panel nonmodally...
> 
> I'd like to present an informational alert for n seconds then dismiss it 
> without user interaction. But I don't see any way to dismiss, terminate, 
> cancel, invalidate, etc. an NSAlert object.
> 
> I know this is possible in iOS, but is there no way to do this in MacOS, 
> other than displaying/hiding an NSPanel of my own?
> 
> -Carl
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: fileManagerWithAuthorization:

2021-03-15 Thread Keary Suska via Cocoa-dev
That forum thread does not, as far as I can tell, say that you need a 
provisioning profile for non-sandboxed apps. In fact, the final recommendation 
is to turn off sandboxing to test privileged operations without the need for 
entitlements.

However, it appears an app must still be notarized 
(https://developer.apple.com/news/?id=09032019a) and may need user granted 
permission to access certain areas.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Mar 15, 2021, at 12:44 AM, Allan Odgaard via Cocoa-dev 
>  wrote:
> 
> On 14 Mar 2021, at 19:44, Michael Tsai wrote:
> 
>> I think you need to apply to Apple and get a provisioning profile, even if 
>> the app isn't sandboxed:
>> 
>> https://developer.apple.com/forums/thread/653890
> 
> Thanks, what a disappointing policy decision by Apple. Especially when they 
> are trying to get rid of most other privileged file operation API.
___

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: Programmatically created NSButton is drawn in the wrong position.

2020-12-15 Thread Keary Suska via Cocoa-dev
Based on what you are doing, setting the property to YES will get you closer to 
what your problem is. When this property is NO, you cannot accurately control 
the view’s frame.

That being said, when are you verifying that the frame of the buttons is 
unchanged?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Dec 15, 2020, at 3:49 AM, Eyal Redler via Cocoa-dev 
>  wrote:
> 
> setting translatesAutoresizingMaskIntoConstraints to yes makes the situation 
> worse. The buttons are drawn further away than their frames indicate.
> 
> Eyal
> 
>> On 15 Dec 2020, at 4:05, Ben Kennedy  wrote:
>> 
>> 
>>> On 14 Dec 2020, at 5:39 pm, Eyal Redler via Cocoa-dev 
>>>  wrote:
>>> 
>>> button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
>>> [button setTranslatesAutoresizingMaskIntoConstraints:NO];
>>> [button setBezelStyle:NSRoundedBezelStyle];
>>> [button setTitle:buttonTitle];
>>> [button sizeToFit];
>>> [button setFrameOrigin:NSMakePoint(position, 20)];
>> 
>> Since you're positioning the frames manually, you need to set 
>> setTranslatesAutoresizingMaskIntoConstraints = YES instead of NO.
>> 
>> -ben
>> 
> 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Keary Suska via Cocoa-dev
Are the timer values actual numeric constants, or a variable defined earlier in 
code?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Apr 29, 2020, at 3:35 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> There are no extensions or categories in the project. 
> I changed the -newData: method name to -arrivalOfNewData:. 
> I changed the newTimer variable name to theTimer. 
> I rebooted the machine. 
> 
> No joy.
> 
> I realize this is no longer a Cocoa problem, but what - even theoretically - 
> could cause this? 
> As shown in the debugger, the timer gets created with the wrong time interval 
> value, by a consistent factor of 20.
> 
> -Carl
> 
> 
>> On Apr 29, 2020, at 2:24 PM, Andy Lee  wrote:
>> 
>> I did the same just now in a macOS project.  Copied your code and added a 
>> newData: method.  This is with Xcode 11.2.1 on Mojave, 10.4.6.  Works fine 
>> for me.  Weird!
>> 
>> @implementation AppDelegate
>> 
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>>NSTimer *newTimer = [NSTimer timerWithTimeInterval:1.0  // should be 1/sec
>>target:self
>>  selector:@selector(newData:)
>>  userInfo:nil
>>   repeats:YES];
>>[[NSRunLoop mainRunLoop] addTimer:newTimer
>>  forMode:NSRunLoopCommonModes];
>> }
>> 
>> - (void)newData:(NSTimer *)timer {
>>NSLog(@"timer is %@", timer);
>> }
>> 
>> @end
>> 
>> 2020-04-29 17:20:45.331469-0400 NSTimerQuestion[21676:3985041] Metal API 
>> Validation Enabled
>> 2020-04-29 17:20:46.413190-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:47.412968-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:48.413525-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:49.413373-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:50.412610-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> ...
>> 
>> --Andy
>> 
>> On Apr 29, 2020, at 5:15 PM, Alex Zavatone via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> I used your code in an iOS project and it works as expected.
>>> 
>>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>>> 2020
>>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>>> 2020
>>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>>> 2020
>>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>>> 2020
>>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>>> 2020
>>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>>> 2020
>>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>>> 2020
>>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>>> 2020
>>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>>> 2020
>>> 
>>> I’ll mail you the project offlist.
>>> 
>>> 
>>> 
>>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>>> 
>>>> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>>>> 
>>>>> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
>>>>> mailto:cocoa-dev@lists.apple.com> 
>>>>> <mailto:cocoa-dev@lists.apple.com <mailto:cocoa-dev@lists.apple.com>>> 
>>>>> wrote:
>>>>>> 
>>>>>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>>>>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>>>>>> 
>>>>>>> When I issue NSTimer's +timerWithTimeInterval: method, I'm getting 
>>>>>>> unexpected timer firing times (20X faster than expected).
>>>>>>> 
>>>>>>> ∙ If I specify 1.0 for the time interval, my metho

Re: Permission Denied trying to connect to localhost in unit test

2019-12-13 Thread Keary Suska via Cocoa-dev
Yes, you would create a new test target and add all the GUI stuff as a member 
of the test target. Of course, you will want to exclude them from other 
targets. You shouldn’t need to do any library linking since it is a common 
codebase. Simply include the classes and put the glue code in the App Delegate.

Keary Suska
Esoteritech, Inc.


> On Dec 13, 2019, at 7:35 AM, Robert Walsh via Cocoa-dev 
>  wrote:
> 
> Thanks - I just finished doing that.  I stubbed out a simple main that has 
> enough smarts to use this TcpClient the way it will be used in the real app, 
> and I was able to connect to an instance of the server to which the command 
> line tool needs to connect.  This server is running on another machine, not 
> on localhost.  I was able to make this connection without needing to grant 
> any entitlements to the command line tool, so the problem occurs only when 
> trying to run the unit test.  In short, the unit test case is allowed to 
> start a server and accept connections (from telnet, for example), and the 
> class being tested is allowed to connect to an external server when not being 
> run within the test case.  So far, though, the class being tested cannot 
> connect to the server when both are used inside the test case.
> 
> I can probably move forward by testing this particular class the old 
> fashioned way through manual inspection and then mocking it in other classes 
> where it will be used.
> 
> If, though, I want to go the dummy test app route, would I create another 
> target that is a GUI app, either link to a static library containing the 
> testable classes or include them as compile targets, and then create a unit 
> test bundle that targets that GUI app?
> 
> Rob
> 
> 
> 
> From: Keary Suska 
> Sent: Friday, December 13, 2019 12:18 PM
> To: Robert Walsh 
> Cc: Cocoa-Dev (Apple) 
> Subject: Re: Permission Denied trying to connect to localhost in unit test
> 
> I would first test to see if you can access networking at all—i.e. connect to 
> a public HTTP server and see if it works. If it doesn’t, then you are 
> probably running against the entitlements issue. I suspect that the “dummy 
> target” indicated is simply a GUI app wrapper built just for testing but not 
> for deployment. Should be easy enough because it doesn’t have to do anything 
> in the GUI.
> 
> Keary Suska
> Esoteritech, Inc.
> 
> 
>> On Dec 13, 2019, at 4:42 AM, Robert Walsh via Cocoa-dev 
>>  wrote:
>> 
>> The errno is 13 (which I think is just a generic Permission Denied).
>> 
>> I am connecting to localhost.
>> 
>> I did find this post in the Apple Developer Forums 
>> (https://forums.developer.apple.com/thread/52211):
>> How do I unittest a command line application? |Apple Developer 
>> Forums<https://forums.developer.apple.com/thread/52211>
>> Yes, you can add the unit testing bundle, but it won't let you set Target to 
>> be Tested.. Right. That’s because the machinery to load your test bundle 
>> within a process only works if the process is based on a GUI framework (like 
>> Cocoa or Cocoa Touch).
>> forums.developer.apple.com
>> 
>> 
>> A command line tool typically does not use a GUI framework and thus the test 
>> machinery is unable to load your bundle into that tool.
>> 
>> However, you can test without an app target.  If you set the Target to be 
>> Tested popup to None, Xcode will load your test bundle into its built-in 
>> ‘test runner’ tool, xctest.
>> 
>> This works well for most but there are some gotchas.  Specifically, if the 
>> code you’re using requires entitlements then you won’t be able to test it 
>> like this because there’s no way to give those entitlements to xctest.  The 
>> standard workaround for that is to add a dummy test target app to your 
>> project.
>> 
>> 
>> Assuming the problem is that I need to add the App Sandbox -> Outgoing 
>> Connections (Client) entitlement to the command line target (since I can't 
>> add any entitlements to the test target; clicking "+ Capabilities" brings up 
>> a dialog saying that capabilities are not support for this target), how do I 
>> create "a dummy test target app?"  As I said before, I created the test 
>> target by using the Unit Test Bundle template, and I don't see any other 
>> relevant choices.
>> 
>> 
>> Rob
>> 
>> 
>> 
>> From: Jens Alfke 
>> Sent: Thursday, December 12, 2019 1:58 PM
>> To: Robert Walsh 
>> Cc: Cocoa-Dev (Apple) 
>> Subject: Re: Permission Denied trying to connect to localhost in unit te

Re: Permission Denied trying to connect to localhost in unit test

2019-12-13 Thread Keary Suska via Cocoa-dev
I would first test to see if you can access networking at all—i.e. connect to a 
public HTTP server and see if it works. If it doesn’t, then you are probably 
running against the entitlements issue. I suspect that the “dummy target” 
indicated is simply a GUI app wrapper built just for testing but not for 
deployment. Should be easy enough because it doesn’t have to do anything in the 
GUI.

Keary Suska
Esoteritech, Inc.


> On Dec 13, 2019, at 4:42 AM, Robert Walsh via Cocoa-dev 
>  wrote:
> 
> The errno is 13 (which I think is just a generic Permission Denied).
> 
> I am connecting to localhost.
> 
> I did find this post in the Apple Developer Forums 
> (https://forums.developer.apple.com/thread/52211):
> How do I unittest a command line application? |Apple Developer 
> Forums<https://forums.developer.apple.com/thread/52211>
> Yes, you can add the unit testing bundle, but it won't let you set Target to 
> be Tested.. Right. That’s because the machinery to load your test bundle 
> within a process only works if the process is based on a GUI framework (like 
> Cocoa or Cocoa Touch).
> forums.developer.apple.com
> 
> 
> A command line tool typically does not use a GUI framework and thus the test 
> machinery is unable to load your bundle into that tool.
> 
> However, you can test without an app target.  If you set the Target to be 
> Tested popup to None, Xcode will load your test bundle into its built-in 
> ‘test runner’ tool, xctest.
> 
> This works well for most but there are some gotchas.  Specifically, if the 
> code you’re using requires entitlements then you won’t be able to test it 
> like this because there’s no way to give those entitlements to xctest.  The 
> standard workaround for that is to add a dummy test target app to your 
> project.
> 
> 
> Assuming the problem is that I need to add the App Sandbox -> Outgoing 
> Connections (Client) entitlement to the command line target (since I can't 
> add any entitlements to the test target; clicking "+ Capabilities" brings up 
> a dialog saying that capabilities are not support for this target), how do I 
> create "a dummy test target app?"  As I said before, I created the test 
> target by using the Unit Test Bundle template, and I don't see any other 
> relevant choices.
> 
> 
> Rob
> 
> 
> 
> From: Jens Alfke 
> Sent: Thursday, December 12, 2019 1:58 PM
> To: Robert Walsh 
> Cc: Cocoa-Dev (Apple) 
> Subject: Re: Permission Denied trying to connect to localhost in unit test
> 
> 
> 
> On Dec 12, 2019, at 7:42 AM, Robert Walsh via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com>> wrote:
> 
> I am writing a command line application in Objective-C that needs to make a 
> TCP connection to a server.  In a unit test for the TcpClient class I am 
> writing, I have a simple TCP server that listens for connections in a thread. 
>  When I try to connect to this socket from the client socket class, connect() 
> fails and perror reports Permission Denied.
> 
> That's odd. I've written plenty of macOS networking code and not seen this 
> problem. What is the errno value?
> 
> The only thing I can guess is that the Xcode test-runner process is being 
> sandboxed to prevent outgoing networking, but I've definitely run TCP 
> connections from XCTests without problems. Are you connecting to "localhost" 
> / 127.0.0.1, or using an explicit IP address?
> 
> —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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: 'altool' cannot be found

2019-06-16 Thread Keary Suska via Cocoa-dev
Looks like something was up with the Cocoa Dev list—you probably see that it 
came in early this morning. Anyway, glad I could be help.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Jun 15, 2019, at 12:14 PM, Leo via Cocoa-dev  
> wrote:
> 
> 
> Thanks Keary,
> 
> You helped me solve the issue.
> 
> altool was indeed in this folder:
> 
> /Applications/Xcode.app/Contents/Developer/usr/bin/
> 
> However, xcode-select -p returned /Library/Developer/CommandLineTools
> 
> I reset the path with xcode-select -r.
> 
> Now everything seems to work.
> 
> 
> Thanks,
> Leo
> 
> 
> 
> 
> 
> On 6/15/19 9:56 AM, Keary Suska wrote:
>> I am using that Xcode version and for a while now all Xcode utilities and 
>> command line tools are installed in the Xcode app package. My copy is at 
>> /Applications/Xcode.app/Contents/Developer/usr/bin/altool. Do you find it in 
>> that location?
>> 
>> If so, xcrun should be able to find it. If you run xcode-select -p does it 
>> show the expected path?
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>>> On Jun 15, 2019, at 12:12 AM, Leo via Cocoa-dev  
>>> wrote:
>>> 
>>> 
>>> Hi all,
>>> 
>>> I wanted to start building a notarization automation script.
>>> 
>>> However, when I try to use the 'xcrun altool' in Terminal, I get the 
>>> following error:
>>> 
>>> xcrun: error: unable to find utility "altool", not a developer tool or in 
>>> PATH
>>> 
>>> I'm on macOS 10.14.5, Xcode 10.2.1.
>>> 
>>> I then especially downloaded and installed Xcode Command Line Tools - still 
>>> get same error.
>>> 
>>> Other tools like stapler do work.
>>> 
>>> I checked this dir and altool is not there: 
>>> /Library/Developer/CommandLineTools/usr/bin
>>> 
>>> Any idea what's going on?
>>> 
>>> 
>>> Thanks for any help!
>>> 
>>> Leo
>>> ___
>>> 
>>> 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/cocoa-dev%40esoteritech.com
>>> 
>>> This email sent to cocoa-...@esoteritech.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: 'altool' cannot be found

2019-06-15 Thread Keary Suska via Cocoa-dev
I am using that Xcode version and for a while now all Xcode utilities and 
command line tools are installed in the Xcode app package. My copy is at 
/Applications/Xcode.app/Contents/Developer/usr/bin/altool. Do you find it in 
that location?

If so, xcrun should be able to find it. If you run xcode-select -p does it show 
the expected path?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Jun 15, 2019, at 12:12 AM, Leo via Cocoa-dev  
> wrote:
> 
> 
> Hi all,
> 
> I wanted to start building a notarization automation script.
> 
> However, when I try to use the 'xcrun altool' in Terminal, I get the 
> following error:
> 
> xcrun: error: unable to find utility "altool", not a developer tool or in PATH
> 
> I'm on macOS 10.14.5, Xcode 10.2.1.
> 
> I then especially downloaded and installed Xcode Command Line Tools - still 
> get same error.
> 
> Other tools like stapler do work.
> 
> I checked this dir and altool is not there: 
> /Library/Developer/CommandLineTools/usr/bin
> 
> Any idea what's going on?
> 
> 
> Thanks for any help!
> 
> Leo
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Crashing in NSTabView

2019-05-22 Thread Keary Suska
When you say "separate, strong reference to each tab view controller” do you 
mean each child view controller that controls a single tab view item, or the 
tab view controller as a whole? It is keeping string references to the 
individual child view controllers that should solve your situation.

You may also want to check out Instrument’s zombies, which might better 
pinpoint where the issue is ocurring.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 22, 2019, at 8:26 AM, Casey McDermott  wrote:
> 
> Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs 
> a few times, one of the NSTabViewItems would release
> prematurely, causing a crash.  So we switched it to using a 
> NSTabViewController.  Tab switching still crashes, but now it releases a
> NSViewController prematurely.  
> 
> Nothing else in the code references tab items or tab controllers.  This is 
> baffling. We can set a breakpoint on dealloc to see when it is deleted, 
> but can't breakpoint on release to see what releases it.  We build with 
> latest Xcode but this has been going on with older ones also.
> 
> We tried adding a separate, strong reference to each tab view controller.  It 
> still crashes, but it takes a few more tab switches before the controller is 
> released.
> 
> Any suggestions for what might be causing this?
> 
> Casey McDermott
> Turtle Creek Software
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: NSTextField "Discard Change"

2019-05-06 Thread Keary Suska
IIRC, you get this behavior automatically when validating with a formatter, so 
applying a custom NSNumberFormatter subclass might be more canonical and less 
kludgey.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 6, 2019, at 5:33 AM, Richard Charles  wrote:
> 
> Thank you Quincey, Sean, Gary and Alex for your comments and suggestions.
> 
> To recap I have a NSTextField subclass bound to an array controller using a 
> derived value binding. The user selects one or more objects in a graphic 
> view. Object properties are shown in an inspector containing the text field.
> 
> A custom derived value binding is needed because object properties are 
> floating point values with limited precision. Values that are close to equal 
> are considered equal from the user's point of view.
> 
> When garbage is entered into a text field and the user presses the return key 
> an alert panel is presented as a sheet attached to the window. The user can 
> choose "Discard Change" or "OK”.
> 
> Because a custom binding is used code must be added to present the error and 
> recover from the error. My text field subclass implements the 
> NSErrorRecoveryAttempting informal protocol.
> 
> My original discard change code did not work.
> 
> - (void)attemptRecoveryFromError:(NSError *)error
>  optionIndex:(NSUInteger)recoveryOptionIndex
> delegate:(id)delegate
>   didRecoverSelector:(SEL)didRecoverSelector
>  contextInfo:(void *)contextInfo
> {
> // Discard Change
> if (recoveryOptionIndex == 1) {
> [self abortEditing]; // does not work
> }
> }
> 
> Here is a solution that works well.
> 
> - (void)attemptRecoveryFromError:(NSError *)error
>  optionIndex:(NSUInteger)recoveryOptionIndex
> delegate:(id)delegate
>   didRecoverSelector:(SEL)didRecoverSelector
>  contextInfo:(void *)contextInfo
> {
> // Discard Change
> if (recoveryOptionIndex == 1) {
> // Revert display back to original value.
> [self abortEditing];
> [self setObjectValue:self.cachedObjectValue];
> [self.window makeFirstResponder:self];
> }
> }
> 
> The abortEditing message is needed otherwise the binding will push the 
> updated cached object value to the model.
> 
> --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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: NSTabViewItem and NSViewController

2019-04-04 Thread Keary Suska
Re-reading my response, I hope it didn’t come across as snarky. If so, I 
apologize, as that wasn’t my intention.

Anyway, I believe that it is expected behavior that a tab view item is released 
when it is removed, and in non-ARC environments that tends to mean a lot of 
autoreleasing, and xib-loading semantics also muddy the water, so some memory 
issues can be hidden and only crop up in certain circumstances. One of the 
reasons for going ARC, I imagine. This could explain the difference, as well as 
possibly some sort of timing issue with how ARC disposes of objects, since the 
tab view item should be gone as well.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Apr 4, 2019, at 9:29 AM, Casey McDermott  wrote:
> 
> The tab view item has a strong reference to the view controller, but the 
> controller is released
> even though the tab view item still exists.  So, selecting the tab hits the 
> controller ref and it
> crashes with EXC_BAD_ACCESS.  My guess is it's released when the NSTabView
> switches views, but a breakpoint at dealloc doesn't help much.
> 
> However, we were not using a NSTabViewController.  We'll try that now.
> 
> Thanks,
> 
> Casey McDermott
> Turtle Creek Software 
> 
> --------
> On Thu, 4/4/19, Keary Suska  wrote:
> 
> Subject: Re: NSTabViewItem and NSViewController
> To: "Casey McDermott" 
> Cc: "Cocoa-Dev (Apple)" 
> Date: Thursday, April 4, 2019, 10:01 AM
> 
> Who owns the view controller?
> Apparently, no-one, sine ARC is deallocating it once the
> last reference to it (the tab view item) is deallocated. If
> there is supposed to be an owner, make sure the owner’s
> reference is strong. If you can target 10.10+, using
> NSTabViewController is probably a better choice.
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or
> business"
> 
>> On Apr 4, 2019, at
> 7:43 AM, Casey McDermott 
> wrote:
>> 
>> We have a
> tab view with tabs added from code.  Each tab uses a
> NSTabViewItem subclass,
>> which contains
> a reference to a NSViewController subclass within it to
> manage tab contents. 
>> Users click to
> add and remove tabs.
>> 
>> It works fine without ARC, with the
> NSTabView controlling the viewer lifetime.
>> With ARC, it works fine with one tab. 
> However the view controller is released and deallocated
>> when a second tab is added, so switching
> tabs causes a crash from the invalid reference.
>> 
>> Is there some way to
> see what is releasing the view controller?   It's
> nothing in our code.
>> NSTabView seems
> the likeliest culprit?
>> 
>> NSTabViewItem is not a NSView subclass.
> Does that prevent it from managing lifetime for a view and
> view controller?
>> 
>> 
> Thanks,
>> 
>> Casey
> McDermott
>> Turtle Creek Software
> 
>> 
> ___
>> 
>> 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/cocoa-dev%40esoteritech.com
>> 
>> This email sent to
> cocoa-...@esoteritech.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: NSTabViewItem and NSViewController

2019-04-04 Thread Keary Suska
Who owns the view controller? Apparently, no-one, sine ARC is deallocating it 
once the last reference to it (the tab view item) is deallocated. If there is 
supposed to be an owner, make sure the owner’s reference is strong. If you can 
target 10.10+, using NSTabViewController is probably a better choice.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Apr 4, 2019, at 7:43 AM, Casey McDermott  wrote:
> 
> We have a tab view with tabs added from code.  Each tab uses a NSTabViewItem 
> subclass,
> which contains a reference to a NSViewController subclass within it to manage 
> tab contents. 
> Users click to add and remove tabs.
> 
> It works fine without ARC, with the NSTabView controlling the viewer lifetime.
> With ARC, it works fine with one tab.  However the view controller is 
> released and deallocated
> when a second tab is added, so switching tabs causes a crash from the invalid 
> reference.
> 
> Is there some way to see what is releasing the view controller?   It's 
> nothing in our code.
> NSTabView seems the likeliest culprit?
> 
> NSTabViewItem is not a NSView subclass. Does that prevent it from managing 
> lifetime for a view and view controller?
> 
> Thanks,
> 
> Casey McDermott
> Turtle Creek Software 
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Silly question on extending NSObject.

2019-02-19 Thread Keary Suska
Rob, how, exactly, would Alex do that such that all objects inheriting from 
NSObject will automatically have the implementation, which seems to be the goal?

The issue with .pch, as I understand it, is that Xcode wants to get away from 
using precompiled headers, and there are various philosophical and practical 
reasons for doing so, which you can google on. Further, .pch files are not 
intended to be a global import, although that is what many developers 
(including myself) have used them for.

In your case you can simply put the import in a place that you know will be 
loaded first, such as your App delegate class.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Feb 19, 2019, at 2:37 PM, Rob Petrovec  wrote:
> 
> Why not use/override -description or -debugDescription instead of 
> re-inventing the wheel?
> 
> —Rob
> 
>> On Feb 19, 2019, at 2:23 PM, Alex Zavatone  wrote:
>> 
>> Sorry.  Second try.
>> 
>> In most Objective-C projects I add an autodescribe category on NSObject and 
>> put the import for the category header into a .pch for the project so that 
>> it will be available for every class in the project.
>> 
>> This lets me dump an object’s properties and values at Will in the debugger.
>> 
>> Is there a more modern way to do this than using a .pch?
>> 
>> I’ll also be adding one for Swift and am interested in approaches for both.  
>> 
>> Put the import in Settings.xcconfig files?
>> 
>> Thanks in advance
>> 
>> Sent from my iPhone
>> 
>>> On Feb 19, 2019, at 3:15 PM, Alex Zavatone  wrote:
>>> 
>>> In most Objective-C projects I add an autodescribe category and put the
>> 
>> ___
>> 
>> 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/petrock%40mac.com
>> 
>> This email sent to petr...@mac.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: is there a way to determine if an NSButton is toggleable ?

2018-08-20 Thread Keary Suska
The docs indicate that the button “type” is not actually a property itself. The 
setter simply sets some group of properties to reflect the behavior represented 
by the button type constant. NSButtonCell showsStateBy property value might be 
the closest thing. You might also put a breakpoint on setState: to see if it is 
being set when it shouldn’t, and maybe by whom.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Aug 20, 2018, at 4:04 AM, Guillaume Laurent  
> wrote:
> 
> Hi all,
> 
> 
> For a custom UI I’ve had to write a custom control deriving from NSButton, 
> which highlights itself in a special way on mouse-over. In the method which 
> does the highlighting, I check if the button’s state is either .on or .off, 
> so I know which title or alternateTitle to display. But I realized that, no 
> matter the button's type, the state is always toggled on click. That is, even 
> if the button’s type is set to MomentaryPushIn, the button’s state is toggled 
> after a click. I’d have thought that this was the case only for 
> OnOff/Toggle/Switch… types.
> 
> Since there is no NSButton.type getter, is there a way to determine if the 
> button’s type is toggleable or not ? And what is the reason for switching 
> state for types like MomentaryPushIn ?
> 
> 
> Thanks,
> 
> Guillaume.
> ___
> 
> 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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: NSComboBox

2018-07-25 Thread Keary Suska
NSComboBox is just a suped-up NSTextField, so you can some sort of validation 
so you can prevent the user from exiting the field if they don’t enter an 
acceptable value. The most basic approach is delegation and doing the check in  
-control:textShouldEndEditing:

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Jul 25, 2018, at 4:40 PM, Casey McDermott  wrote:
> 
> I forgot to mention that the lists may contain 10,000s of items. Maybe 
> 100,000s. 
> Typing to select from NSPopUpButton works OK for short lists.  I just made a 
> test 
> popup with 300 items and it's already awkward.  10K would be absurd.
> 
> These are business records, and users may data enter hundreds a day.  They 
> want 
> to tab, type a few letters to select a customer, tab to the next field, type 
> a bit to
> select an inventory item, etc.  Type a customer that doesn't exist and it 
> should beep 
> and ignore the keystrokes.  If they need to enter a new customer, it's a 
> right-click, 
> then a panel to enter more than just the name.
> 
> Our current interface does use popup buttons for some things, but people 
> complain
> about them.  They don't want to take hands off keyboard.  We plan to convert 
> those 
> to combo boxes so it can be completely mouseless.
> 
> That "disambiguating field" article by Tog may be on one of the developer 
> CDs.  
> I can't find it online. It explained this use case very well, and interface 
> to solve it. 
> It was a major reason why we switched from Excel templates to a C++ app.
> NSComboBox is close, but we need it confined to existing items.
> 
> Thanks,
> 
> Casey McDermott
> 
> Turtle Creek Software 
> http://www.turtlesoft.com 
> 607 220-4514
> 
> 
> On Wed, 7/25/18, Jens Alfke  wrote:
> 
> Subject: Re: NSComboBox
> To: "Casey McDermott" 
> Cc: cocoa-dev@lists.apple.com
> Date: Wednesday, July 25, 2018, 2:51 PM
> 
> 
> 
> On
> Jul 25, 2018, at 10:45 AM, Casey McDermott 
> wrote:
> The
> goal is to auto-fill an account from what they type, and
> ignore typing if not a match.
> 
> That sounds like the regular behavior
> of NSPopUpButton: after clicking to pop up the menu, you can
> type-select items from it. 
> (Although it doesn't ignore
> mismatches, it just selects the closest item.)
> —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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Creating object graph in swift, Core Data or vanilla objects?

2018-03-21 Thread Keary Suska
In that case the only way to avoid having to remove objects first, that I can 
think of, is to create your own custom persistent store. It’s not too hard, and 
might be a better solution in the long run anyway.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Mar 21, 2018, at 9:52 AM, Glen Huang <hey...@gmail.com> wrote:
> 
> Thanks for the suggestion Keary, but some view controllers only load portion 
> of the whole graph.
> 
> For example, in the home screen, I show a list of clubs, and when a user taps 
> a club, I show its members. Showing members shouldn’t wipe out the whole 
> graph, but I do would like to make sure its members are empty before I import 
> its member json.
> 
>> On 21 Mar 2018, at 11:46 PM, Keary Suska <cocoa-...@esoteritech.com> wrote:
>> 
>> Why not just use a different persistent store instance each time? An 
>> in-memory store shouldn’t be terribly expensive to create, and you can 
>> either keep or dispose of other stores as you need.
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>>> On Mar 21, 2018, at 7:40 AM, Glen Huang <hey...@gmail.com> wrote:
>>> 
>>> Thanks for the suggestion Alex.
>>> 
>>> I’m not sure making attributes transient would work though, because the 
>>> objects themselves would still be persisted, you can still save the context 
>>> and fetch them back, only that they don’t contain any attributes, if I’m 
>>> not wrong.
>>> 
>>> By refreshing the object graph, do you mean updating managed objects 
>>> instead of deleting and creating? I thought about that, but it seems 
>>> something quite difficult to do, because I have to compare the json with 
>>> the graph and figure out what should be created/deleted/updated, and it 
>>> still requires me to create the graph from scratch when the store is empty. 
>>> That’s why I’m looking for ways to have a clean sheet before importing 
>>> json, so I only have one way to manage the object graph (tear down and 
>>> create from scratch).
>>> 
>>>> On 21 Mar 2018, at 9:27 PM, Alex Finkel <finkel.a...@gmail.com> wrote:
>>>> 
>>>> if you dont want to persist anything, why not make all the attributes 
>>>> transient?  But I would still persist, and just refresh the object graph 
>>>> with the response based on how often the data may change. 
>>>> 
>>>> On Wed, Mar 21, 2018 at 4:56 AM, Glen Huang 
>>>> <hey...@gmail.com<mailto:hey...@gmail.com>> wrote:
>>>> Hi,
>>>> 
>>>> I'm using Core Data as my model, but I don't want to actually persist 
>>>> anything. Anytime a view controller is shown, I load json data from my 
>>>> server and populate the store.
>>>> 
>>>> The problem is that objects in Core Data persist between view controllers, 
>>>> even with in-memory store type. But when I load json data, I’d like to 
>>>> have a fresh start. So it seems I need to remove existing objects first.
>>>> 
>>>> You might say I shouldn't use Core Data in this case, just use vanilla 
>>>> objects. But Core Data solves lots of problems, like no need to worry 
>>>> about memory leak for circular dependencies (my model is pretty complex, 
>>>> lots of many-to-many relationships etc), NSFetchedResultsController, etc. 
>>>> And with vanilla objects, when you have a many-to-many relationship, it’s 
>>>> seems it’s impossible to prevent memory leak:
>>>> 
>>>> class Club {
>>>> var people: [Person]
>>>> }
>>>> class Person {
>>>> var name: String
>>>> var clubs: [Club]
>>>> }
>>>> 
>>>> Array in swift always create strong reference if I’m not wrong, and the 
>>>> two arrays can create circular references.
>>>> 
>>>> If I go with Core Data, to easily delete objects and have a fresh start, 
>>>> one solution involves carefully setting up delete rule between object 
>>>> models and then deleting ones at the level I want, and hope it could 
>>>> cascade throughout, but the problem is that this approach is very error 
>>>> prone. If I misconfigure some delete rules, there won’t be any errors, 
>>>> still leaving some objects in the store.
>>>> 
>>>> I wonder what’s the best way to create object graph in swift without the 
>>&g

Re: Creating object graph in swift, Core Data or vanilla objects?

2018-03-21 Thread Keary Suska
Why not just use a different persistent store instance each time? An in-memory 
store shouldn’t be terribly expensive to create, and you can either keep or 
dispose of other stores as you need.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Mar 21, 2018, at 7:40 AM, Glen Huang <hey...@gmail.com> wrote:
> 
> Thanks for the suggestion Alex.
> 
> I’m not sure making attributes transient would work though, because the 
> objects themselves would still be persisted, you can still save the context 
> and fetch them back, only that they don’t contain any attributes, if I’m not 
> wrong.
> 
> By refreshing the object graph, do you mean updating managed objects instead 
> of deleting and creating? I thought about that, but it seems something quite 
> difficult to do, because I have to compare the json with the graph and figure 
> out what should be created/deleted/updated, and it still requires me to 
> create the graph from scratch when the store is empty. That’s why I’m looking 
> for ways to have a clean sheet before importing json, so I only have one way 
> to manage the object graph (tear down and create from scratch).
> 
>> On 21 Mar 2018, at 9:27 PM, Alex Finkel <finkel.a...@gmail.com> wrote:
>> 
>> if you dont want to persist anything, why not make all the attributes 
>> transient?  But I would still persist, and just refresh the object graph 
>> with the response based on how often the data may change. 
>> 
>> On Wed, Mar 21, 2018 at 4:56 AM, Glen Huang <hey...@gmail.com 
>> <mailto:hey...@gmail.com>> wrote:
>> Hi,
>> 
>> I'm using Core Data as my model, but I don't want to actually persist 
>> anything. Anytime a view controller is shown, I load json data from my 
>> server and populate the store.
>> 
>> The problem is that objects in Core Data persist between view controllers, 
>> even with in-memory store type. But when I load json data, I’d like to have 
>> a fresh start. So it seems I need to remove existing objects first.
>> 
>> You might say I shouldn't use Core Data in this case, just use vanilla 
>> objects. But Core Data solves lots of problems, like no need to worry about 
>> memory leak for circular dependencies (my model is pretty complex, lots of 
>> many-to-many relationships etc), NSFetchedResultsController, etc. And with 
>> vanilla objects, when you have a many-to-many relationship, it’s seems it’s 
>> impossible to prevent memory leak:
>> 
>> class Club {
>>  var people: [Person]
>> }
>> class Person {
>>  var name: String
>>  var clubs: [Club]
>> }
>> 
>> Array in swift always create strong reference if I’m not wrong, and the two 
>> arrays can create circular references.
>> 
>> If I go with Core Data, to easily delete objects and have a fresh start, one 
>> solution involves carefully setting up delete rule between object models and 
>> then deleting ones at the level I want, and hope it could cascade 
>> throughout, but the problem is that this approach is very error prone. If I 
>> misconfigure some delete rules, there won’t be any errors, still leaving 
>> some objects in the store.
>> 
>> I wonder what’s the best way to create object graph in swift without the 
>> risk of leaking memory, if Core Data is the way to go, is there any better 
>> way to easily detect objects that I forgot to delete? Or is there a better 
>> way that I can guarantee that the store is clean before importing json data?
>> 
>> Best,
>> Glen
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
>> <mailto: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 
>> <http://lists.apple.com/>
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/finkel.alex%40gmail.com 
>> <https://lists.apple.com/mailman/options/cocoa-dev/finkel.alex%40gmail.com>
>> 
>> This email sent to finkel.a...@gmail.com <mailto:finkel.a...@gmail.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/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.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: Popup-Menu Binding issue in Cell-based NSTableView

2018-01-04 Thread Keary Suska
> On Jan 4, 2018, at 12:27 AM, Motti Shneor <motti.shn...@me.com> wrote:
> 
>>> If I last elect to add such out-of-table popup - can you think of a decent 
>>> way to disable opening those in-table popup button cells when more than one 
>>> line is selected?  
>> 
>> If you choose this route I think a better UI is to change the in-table popup 
>> bindings to apply to only the specific row. I wouldn’t disable the popup in 
>> this case as it will always behave as expected, and disabling would seem to 
>> be an odd UI to me.
> 
> But it is very confusing. You select 5 lines, then press the popup and it 
> opens. Then you select some new “Species” option. Mac UI rule is “Action is 
> always applied to current selection”.

It is just my little quibble, and worth the grain of salt that it is, but I 
would say that behavior is not typical in a table, where the controls in a row 
are expected to act on that row only. For instance, if the control was a 
checkbox or radio button, would you expect it to effect every selected row, or 
the row with the control? A popup menu is just a larger arbitrary set of 
options, but essentially serves the same purpose as those controls. Now, if it 
was a “command” type, i.e. that it didn’t show a value but allowed a user to 
select an action, by all means it should effect the selection. But being in 
every row would then seem odd ;-) Anyway,  I wouldn’t say it is necessarily a 
bad UI, and as long as you have also implemented robust undo it would be 
probably be OK for most people. 

> However - when I uncheck the same thing on the same binding on the 
> NSTableColumn / NSPopupButtonCell — nothing happens!!! this is mighty weird 
> for me. 

You mean it doesn’t disable on multiple selection? At any rate there are 
clearly some oddities with in-table bindings.

> I remember you wrote “Table editing mechanism is interfering” - but how? and 
> how can I affect it? 

I might be talking out of my hat but I think that what might be happening is 
that the table knows you clicked in a row but is letting the popup handle it 
(because the control need to to operate properly) but on mouse-up the table 
decides to handle the click by changing its selection to to clicked-in row. You 
can verify this by implementing -tableViewSelectionDidChange: (as delegate or 
just observe notification) and checking the model value to see whether it had 
changed. If it hadn’t, it means that the tableview is changing the selection 
before bindings can apply its change.

If this turns out to be the case, one possible workaround is to cache the 
selection and apply the change to all previously selected items and re-select. 
Since you only want to do this when changing the “species” value you can use 
KVO to detect a change. 


> Here I have some success — I was able to implement the NSMenuValidation 
> protocol, and Identify both popup button’s menu-items, using their TAG. When 
> binding the “Content” and “Content Values” of those popups, you can specify 
> “Content Placement Tag” (an integer)  and then you can tag a template 
> menu-item in the .xib with the same number, and it will be replaced by the 
> content.
> 
> Now when content binding replaces the single template menuItem with all those 
> entities - ALL OF THEM carry that tag!!! so here’s how I could do it last.
> 
> My validation is… well…. VERY complicated in this case, and I was able to 
> write only part of it now, to the point where 
> 1. Invalid items get disabled.
> 2. Invalid item titles are modified to include the REASON for invalidation 
> (hard to explain - scientific software)
> 2. Invalid items get HIDDEN — unless the “Option” key is pressed. 
> 
> This is beautiful - same validation applies to both Popup outside the table 
> and in the table. 
> 
> Still it maddens me - the popup OUTSIDE the table behaves very strangely on 
> the display. Sometimes it will “honor” the option key, sometimes not. Every 
> time I press that popup button the whole window resizes and the popup becomes 
> bigger and bigger, although it doesn’t display anything very long. Maybe some 
> auto layout issue, I don’t know - but still this is strange.

Can’t say, but if your assumption on autolayout is correct, it should only 
resize based on the content, so it shouldn’t always go up, it should also go 
down when the content is shorter.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Popup-Menu Binding issue in Cell-based NSTableView

2018-01-02 Thread Keary Suska
ou are hitting an edge case of 
the bindings implementation or that they aren’t designed to work the way you 
want. I don’t think there is a way around that—I think the only solutions will 
likely be outside of the bindings system itself.

>>> When the content of a popup-button-cell is populated by binding - Can I 
>>> still apply NSMenu Validation protocol to that menu, and 
>>> Filter/Enable/Disable menu items as user clicks to open the menu?
>> 
>> I would say, generally, no, as you either have to set the delegate of the 
>> menu or action of each item. The former you might be able to do with a table 
>> delegate method, but you may not be able to do the latter depending on when 
>> bindings populates the popup.
> 
> Well - this I was able to do now - but with one strange behavior. I added the 
> -(BOOL) validateMenuItem:(NSMenuItem *)menuItem to my Window controller, and 
> it IS called for each and every item in the popup buttons - both in the 
> NSTableView and outside it. The problem is - how to identify these items in 
> the method. For other menus in my app - I use tags. but these popup-button 
> menus are populated by binding in runtime. I tried to identify them using 
> IBOutlet - pointers to the menus in the .xib, but strangely - the in-table 
> menu in runtime is not the same as the one in the IBOutlet. It looks like the 
> NSPopupButtonCell is duplicating the original menu, and populates the copy. 

Interesting on menu validation, though I would expect what you are seeing and I 
agree with your conclusions. Every popup cell in a table column must be a 
different object. Did you check to see whether the -representedObject of the 
NSMenuItem is being set? I don’t recall whether bindings does this, but if it 
does, you can use its unique ID (if you have a developer-specified ID) or have 
the tag be a property on the entity. If you can know that the menu title is 
always unique you can always test on that.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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: Popup-Menu Binding issue in Cell-based NSTableView

2018-01-01 Thread Keary Suska
> On Jan 1, 2018, at 2:46 AM, Motti Shneor <motti.shn...@me.com> wrote:
> 
> Hello everyone. Please excuse the anachronism, I am maintaining an old Mac 
> Application written early 2014 when Swift was not an option.  Pure Obj-C, 
> CoreData, and “No-custom-UI” approach.
> 
> I have an NSCell based NSTableView, whose columns are bound to an 
> NSArrayController, whose Content-Array in turn is bound to some CoreData 
> to-many relation - thus the table shows all the related entities.
> 
> Say we have a “WaterSample” entity, and the to-many relation is called 
> “measurements” and each Measurement has length, width, depth, colony-size and 
> species properties - each bound to one of the NSTableColumns. So far - the 
> very basic and stranded use of binding.
> 
> Of the Measurement properties - the species - is yet another to-one relation 
> to the  “Species” table. To allow the user to edit/change the species of a 
> Measurement (line in the table) I have placed a Popup Button Cell in the 
> “Species” column, and bound it like this:
> 
> Content  bound to Species Array Controller, Controller Key: arrangedObjects, 
> Content Placement Tag: 0
> Content Values  bound to Species Array Controller, Controller Key: 
> arrangedObjects, Model Key Path: codeAndName, Content Placement Tag: 0,  
> Multiple Values Placeholder: Multiple Species
> Selected Object  bound to Measurements Array Controller, Controller Key: 
> arrangedObjects, Model Key Path: species, Allows Editing Multiple Values 
> Selection, Conditionally Sets Enabled, Creates Sort Descriptor
> 
> Now it SEEMS to KIND-OF work, (I see the species codes and names, user can 
> click the popup button on each row to see and select from all our Species, 
> and even change the species to another one.
> 
> But I have these issues:
> 
> 1. When I select several Measurement rows of the table — All with the same 
> Species— and click the popup button on any row - it shows “Multiple Species” 
> as the selected value - although all rows have the same species selected.

My understanding (which could be wrong) is that this would be expected 
behavior. I.e., NSArrayController is agnostic about the actual values so either 
displays the single value or the placeholder if multiple values are selected, 
regardless of whether they are the same. I don’t think there is a non-hacky way 
to accomplish what you want, but you can play around with the 
contentArrayForMultipleSelection binding to see if you can get close.

> 2. Selecting a species only applies to the row where I clicked the popup 
> button - not to all selected rows. After releasing the mouse the selection 
> reduces to just one row - but it is terribly confusing.

I suspect that you are running afoul of trying to use bindings in a way that 
they are not intended. Editing multiple values is designed to be used in a 
master-detail type interface, and you are combining that with in-table editing. 
To verify this, have a single popup outside of the table with the same bindings 
except selected object to array controller->selection and see if you get the 
behavior you prefer.

I would say that the UI you are trying to create is rather confusing...

> 3. The editing is immediate, via binding, and I did not find any place to 
> interfere (Say I need to re-calculate things as species changed, or even 
> prevent the change if the newly-selected  species is not compatible with the 
> original.

You cannot intercept bindings, except to do validation, so whatever you do must 
be after-the-fact.

> I have set up a menu Action to the popup-button-cell - and it is called - but 
> the change is already done in the model.
> 
> My questions: 
> Is there anything wrong in my binding settings?

Probably, see my inline response above.

> When the content of a popup-button-cell is populated by binding - Can I still 
> apply NSMenu Validation protocol to that menu, and Filter/Enable/Disable menu 
> items as user clicks to open the menu?

I would say, generally, no, as you either have to set the delegate of the menu 
or action of each item. The former you might be able to do with a table 
delegate method, but you may not be able to do the latter depending on when 
bindings populates the popup.

> When the editing is done via the “Selected Object” binding - can I still 
> somehow intervene and “Catch” the change in code before it happens?

See above.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: What do the font-related Cocoa Bindings in NSTableView and NSTableColumn do?

2017-04-05 Thread Keary Suska

> On Apr 4, 2017, at 4:34 PM, Daryle Walker <dary...@mac.com> wrote:
> 
> 
>> On Apr 4, 2017, at 9:57 AM, Keary Suska <cocoa-...@esoteritech.com> wrote:
>> 
>> 
>>> On Apr 3, 2017, at 5:40 PM, Daryle Walker <dary...@mac.com> wrote:
>>> 
>>> Is there a way to affect the font of a table cell via Bindings? The few 
>>> times I tried, at the NSTextField level (NSTableCellView does not have any 
>>> font-related Bindings), resulted in Xcode’s XIB compiler jamming. (I always 
>>> cancel and take out the change.)
>> 
>> Remember that NSTableCellView subviews cannot bind outside of the 
>> NSTableCellView. The easiest approach is to have the font a property on the 
>> model object set as NSTableCellView’s objectValue, and bind to that.
> 
> My model just stores strings.

So? Do you have a religious belief against mixing class properties? (Sorry, 
couldn’t resist ;-) If the issue is persistence, the value would be transient 
and not stored (as it is stored elsewhere).

> So, I would have to make a value-transformer that reads the font preference 
> from the user-defaults and create a attributed-string with the model string 
> in the desired font?

You could, but you wouldn’t be able to easily update the UI when the font is 
changed.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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: disable group of controls

2017-04-05 Thread Keary Suska

> On Apr 5, 2017, at 5:05 AM, J.E. Schotsman <jesc...@xs4all.nl> wrote:
> 
> 
>> On 05 Apr 2017, at 11:48, Jack Carbaugh <intrn...@aol.com> wrote:
>> 
>> Get a list of the controls then loop through it, setting each enabled 
>> property to false. The container holding them will hold a reference to them
> 
> That way you lose the latent enabled state.
> When the embedder is set to disabled some of the sub controls may already be 
> disabled.

How so? You can have multiple enabled bindings on a control, and if any return 
NO the control stays disabled. If you aren’t using bindings for the “latent” 
state, the responsible controller can observe the group disable property and 
adjust accordingly.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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: How do I set a NSTextView's font in Interface Builder?

2017-03-24 Thread Keary Suska

> On Mar 24, 2017, at 3:08 PM, Jens Alfke <j...@mooseyard.com> wrote:
> 
>> On Mar 24, 2017, at 11:28 AM, Keary Suska <cocoa-...@esoteritech.com> wrote:
>> 
>> I don’t believe that is actually true. Attributes *can* apply to an empty 
>> range. 
> 
> It may be that the serialized form of the string in the nib doesn’t preserve 
> the attributes. Or that they’re not preserved by the view when the user types 
> the first character. (It’s been about eight years since I dealt with this 
> problem…)

I think that is certainly the case—I have never been able to get attributes to 
persist that were specified in IB, though I haven’t tried with the new Xcode 
options.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: How do I set a NSTextView's font in Interface Builder?

2017-03-24 Thread Keary Suska

> On Mar 24, 2017, at 10:33 AM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Mar 23, 2017, at 6:35 PM, Daryle Walker <dary...@mac.com> wrote:
>> 
>> I have the NSTextView selected in its storyboard scene. And I have the 
>> Attributes Inspector active. The entry for the font is empty. Clicking the 
>> squared-T gives a pop-up with a “Custom” font and changing it to one of the 
>> fixed selections (User, fixed) doesn’t do any actual change. 
> 
> This is a longstanding bug, or maybe it’s an API issue. The problem is that 
> the view’s text is empty, and an empty NSAttributedString can’t have any 
> attributes because the attributes are associated with characters.
> 
> IIRC you can fix this by adding some placeholder text, even a single space, 
> in the view, then replacing it at runtime.

I don’t believe that is actually true. Attributes *can* apply to an empty 
range. Alternatively, or additionally, I believe if you call 
setTypingAttributes: on an empty text view that any new types text will use the 
specified attributes.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Handling Cocoa Bindings over a tree of View Controllers

2017-03-21 Thread Keary Suska

> On Mar 21, 2017, at 6:26 AM, Daryle Walker <dary...@mac.com> wrote:
> 
> A design for my third window iteration involves using several 
> NSViewController subclasses in a UI tree. The current (i.e. second) version 
> just has the root NSViewController and a bunch of NSView objects. There is a 
> NSObjectController and a NSArrayController to bind the various view objects 
> to my CoreData-based document data. 
> 
> Since all the objects are together, I can make a big Bindings network. The 
> new design would spread the components. I need the object controllers to 
> synchronize their editing notifications. I'm wondering how.
> 
> I'm half asleep, but I'm thinking of starting with the NSWindowController 
> with a reference to the model and one NSObjectController. That object 
> controller points to the model and it's managed context. For all the 
> NSViewControllers in the tree, they'll use the first object controller as 
> their represented object and reference it for their Bindings needs. Would 
> that work?

You didn’t sat whether your data model is monolithic (e.g. all properties of a 
single object) or a strcutured collection of objects, but in any case I have 
implemented similar structures and I would say that, generally, if your design 
warrants distinct component views, then your data model also warrants 
encapsulating the corresponding data components. I.e. the data structure would 
mirror the view structure to some extent. This isn’t necessary, but IMHO is 
clearer. Worst case you simply set every view controller’s representedObject to 
the entire document model. 

I don’t recommend creating complex binding chains as they can be difficult to 
manage and debug. You only need an object controller for each view, and there 
is no need for controllers to synchronize as that will happen automatically 
with model changes.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: How hard is it to make a NSOrderedSetController?

2017-02-18 Thread Keary Suska

> On Feb 18, 2017, at 4:44 PM, Daryle Walker <dary...@mac.com> wrote:
> 
> I’m using a NSValueTransformer object to convert my Core Data to-many ordered 
> relationship from a NSOrderedSet to a NSArray so NSArrayController can use 
> it. I just connected a NSButton to the controller’s “add:” action. I get this:
> 
>> NSManagedObjects of entity 'Message' do not support 
>> -mutableArrayValueForKey: for the property ‘header'
> 
> So it seems that the controller skips my converted value and tries to alter 
> the property directly, which it can’t. I thought that the problem was that 
> NSOrderedSet.array returns an array of funny proxies, but manually copying to 
> a NSMutableArray and returning that didn’t work either. So it seems that I 
> have to make custom actions to add objects, and hopefully the controller will 
> see the changes.
> 
> But I’m wondering if I should go nuclear and create the 
> NSOrderedSetController that Apple should have done years ago. I don’t know 
> how hard this’ll be. It would be a serving-side Binding class. It would 
> inherit from NSObjectController since NSArrayController would have those 
> extra NSArray/NSSet connection methods.
> 
> Does the Bindings section of the Interface Builder section of Xcode hard-code 
> the Bindings list, or will it create entries for custom Binding-capable 
> classes? If the answer is no customization, then I would have to connect the 
> NSManagedObject instance to the controller in code.

OTOH, it may be easier to implement a to-many accessor pattern for the 
attribute 
<https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueCoding/DefiningCollectionMethods.html#//apple_ref/doc/uid/1107i-CH17-SW1>.
 You may need to use a different key name to get prevent Core Data from 
interfering, say “headerAsArray” or whatever.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Some help with NSComparisonPredicate please

2017-02-17 Thread Keary Suska

> On Feb 17, 2017, at 7:41 AM, sqwarqDev <sqwarq...@icloud.com> wrote:
> 
> So eventually I discovered that this question has a history. Back in 2008 
> Keary and Garriet discussed this:
> 
> http://webcache.googleusercontent.com/search?q=cache:HXWdzJeGeDcJ:www.cocoabuilder.com/archive/cocoa/208612-nspredicate-containing-contains.html+=4=th=clnk=th=safari
> 
> 
> Alas, none of that worked for me, but that’s exactly the same problem as 
> described.
> 
> I also found some history of it on SO, but I don’t understand the “solution” 
> - which the asker confusingly says “I marking this as the solution even 
> though it doesn’t answer my question because my question was misleading”. 
> 
> http://stackoverflow.com/questions/11476466/use-an-nspredicate-to-detect-not-contains
> 
> I’ve tried all the %K and so on options. I’ve actually even downloaded Xcode 
> 4 and built a test project in 10.7 Lion so I could debug it directly. Always 
> the same error:
> 
> “Unknown type of NSComparisonPredicate given to NSMetadataQuery”.
> 
> LIKE works, but as I said doesn’t give me the right results. MATCHES fails, 
> as does CONTAINS. I’m beginning to think this is a bug in NSMetadataQuery. 

Have you read the File Metadata Search Programming Guide? You can find it here 
<https://developer.apple.com/library/content/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple_ref/doc/uid/TP40001849-CJBEJBHH>
 According to that document, only a very limited subset of predicate syntax is 
supported, and it uses special parsing rules. The correct syntax is probably:

kMDItemFSName ==[c] *%@*

As long as the parser is OK with the %@ placeholder, which the docs don’t state 
directly so an alternative would be to construct the string before passing to 
-predicateWithFormat:

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Table selection and bindings

2017-02-14 Thread Keary Suska

> On Feb 14, 2017, at 8:37 AM, John Brownie <john_brow...@sil.org> wrote:
> 
> I have an NSTableView in a document window, and a utility window which 
> functions as an inspector, so its content is bound to the selected object in 
> the table in the document window. Everything seems fine, but there is a place 
> which doesn't function as I expect.
> 
> In the inspector, I can change the display name of the object, which makes 
> the table drop its selection, so that nothing is selected any more. All OK, 
> but the tableViewSelectionDidChange: delegate method isn't called in this 
> instance. In a way, I can see that it's not the user changing the selection, 
> but the problem becomes that now the inspector is still pointed at an object, 
> but there's no selection, and the logic goes badly wrong.
> 
> Am I doing things incorrectly, or is there something that I can do to ensure 
> that the change to the underlying array shown by the table triggers a 
> selection change?

If you are otherwise getting delegate calls when you manually (i.e. NOT 
programmatically) change the selection, then you are running into the 
situations where notifications are not sent when programmatic selection changes 
are made. The only way around this is to watch directly for selection changes, 
which you may be able to accomplish either by observing selectedRowIndexes of 
NSTableView or selectionIndex(es) of an NSArrayController that the table view 
is bond to.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: UI bindings

2017-02-10 Thread Keary Suska

> On Feb 9, 2017, at 5:52 PM, Ariel Feinerman <arielfap...@gmail.com> wrote:
> 
> I have finished the core of my programme and now I am designing the UI. The
> issue is that it has several tabs and about a hundred fields. I wish to
> make a mechanism which can gather values and save them in the hierarchical
> structure of NSArrays and NSDictionaries which I can send to core library,
> save as plist or map into XML. And, of course, I should be able to restore
> UI from it .
> 
> I guess Cocoa Bindings can do all of that. However, I have never used it
> and do not know where to begin. Any examples and suggestions will be highly
> appreciated.

If you haven’t already, read the Key-Value Coding and Key-Value Observing 
guides. Make sure all of your model classes are compliant with both. Then read 
the Cocoa Bindings Programming Topics guide, which has links to all the other 
docs so you can start there if you prefer. Read through all the linked 
supported docs as well. That will be enough for most implementations. If or 
when you get into issues not addressed in those documents you will find most 
answers in the archives. Cocoa bindings have been around for a really long time 
and have changed very little since their inception so any (good) advice on the 
subject will still be relevant regardless of how old. And what is not addressed 
in the archives can be addressed here but please be specific and reference all 
of the involved objects, binding names and key paths.

Oh, and avoid storyboards at this stage as (IMHO) they are unintuitive and 
flout all other MVC documentation.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Intercept Save when closing NSDocument

2017-02-10 Thread Keary Suska

> On Feb 10, 2017, at 9:12 AM, Trygve Inda <cocoa...@xericdesign.com> wrote:
> 
> When I close an NSDocument, it puts up a sheet offering (Don¹t Save,
> Cancel, Save).
> 
> Is there a way to intercept this? I would like to disable the Save button
> for a demo version of our app. I could mark the document as having no
> changes, but then it would just close directly and not allow a cancel
> operation.
> 
> I can easily disable the menu Save/Save As but clicking the Save button in
> the close-sheet window jumps right into the file writing methods in my
> NSDocument subclass.
> 
> Thanks for any ideas.

I would start by overriding -saveDocument: and -saveDocumentAs: in your 
NSDocument subclass with a breakpoint so I can see what is being done. I might 
also start by subclassing 
-runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo: to see 
if that is the method used in these cases. Then there are also autosave issues 
if you intend to support autosave in your app...

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController

2017-02-06 Thread Keary Suska

> On Feb 6, 2017, at 7:43 AM, Steve Mills <sjmi...@mac.com> wrote:
> 
> (Has cocoa-dev been down for days or what?)
> 
> Why is it that most times when I implement a table, it can waste hours of my 
> time?
> 
> So I think I have everything set up like it should be. I'll just jump right 
> to the bug and then we can work back. The problem is that when I edit values 
> in the table, they only seem to get written to the defaults if I add a new 
> item after editing an existing item.
> 
> 1. Run app.
> 2. Edit existing row value.
> 3. Add new row and edit it.
> Result: Edited row is changed, new row has only default value instead of 
> edited value.
> 
> Any ideas?

Warning: the following explanation assumes a scenario that you don’t explicitly 
describe, namely that you are editing an array-type defaults value.

This is a known “issue”, if you want to call it that. As I understand it, the 
problem is that NSUserDefaultsController cannot "deep-observe” array-type 
defaults. I.e., it can watch the array itself for changes but not individual 
array elements because there is no clear key path to a specific array element. 
That is why you see changes when you alter the array itself (by adding/removing 
array elements), but not changes to the values of individual array elements. 
So, this is a limitation to the implementation of KVC/KVO, rather than any 
specific issue with NSUserDefaultsController.

The only way to handle this situation, IMHO, is to have some intermediary or 
user-driven event (like a “commit” button) that “tricks” the defaults 
controller into thinking the entire array has changed when you need to it see 
changes to individual elements.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: On NSIncrementalStore UUID Uniqueness

2017-01-11 Thread Keary Suska

> On Jan 11, 2017, at 11:16 AM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Jan 10, 2017, at 2:00 PM, Jean-Daniel <mail...@xenonium.com> wrote:
>> 
>> UUID means Universally unique identifier and it must be unique: 
>> https://en.wikipedia.org/wiki/UUID 
>> <https://en.wikipedia.org/wiki/UUID><https://en.wikipedia.org/wiki/UUID 
>> <https://en.wikipedia.org/wiki/UUID>>
>> To generate an UUID, use a standard system function (CFUUID, NSUUID, 
>> libuuid, …)
> 
> This is not what I believe Daryle was asking, and it’s sent everyone off on a 
> tangent about what UUIDs are.
> 
> My interpretation of the original question: Is an NSIncrementalStore’s UUID 
> scoped to the specific database, or is it scoped to that _implementation_ of 
> the store? That is, is the UUID generated at runtime or at compile time?
> 
> I don’t know the answer; just hoping to get the discussion back on track :)

The docs say:
"A unique identifier for the store at the given URL. It must be 
uniquely and reproducibly derivable, such that multiple instances of your store 
return the same UUID”

My reading is that the store UUID would be unique to a specific database since 
it is only unique to the URL location of the store. I thin the docs use 
“instance” in a strictly OOP sense.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: On NSPersistentStore Modeling

2017-01-10 Thread Keary Suska

> On Jan 10, 2017, at 4:42 AM, Daryle Walker <dary...@mac.com> wrote:
> 
> I read about store coordinators and managed contexts using Core Data models 
> (I.e. "momd" files). But persistent store subclasses use them too right?

Not exactly. The store will need to know how to translate certain Managed 
Object Model (MOM) related information into how how it stores data. For 
instance, knowing that a specific entity represents a specific table in your 
database. Generally this will encourage the developer to make sure the MOM maps 
to their database schema as closely as possible, but it is not necessary.

> From looking at the docs for the atomic and incremental stores, their 
> internal scheme have to match a specific model too; they can't support 
> generic schemes for arbitrary models, right?

If I understand the question, the answer is no, as long as you implement a 
generic way of translating the MOM into the store’s storage method, which is 
really the correct way to implement an NSPersistentStore subclass.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Connecting NSTextStorage to a string

2016-12-23 Thread Keary Suska

> On Dec 23, 2016, at 8:16 PM, Daryle Walker <dary...@mac.com> wrote:
> 
> The text controls on macOS use a NSTextStorage object to retain their text. 
> That object is a extension of an attributed string. Let's say you use a 
> NSString (or similar) in your document model. How should I get changes on one 
> string to get mirrored on the other?
> 
> I think there are begin/end-editing flag methods on text controls, but how 
> would I go the other way?

In my experience, real-time synchronization of vanilla NSString to an 
NSTextStorage of an NSTextView is painful and fraught with error. Much easier 
to simply set the content of the NSTextView on load (in windowDidLoad or 
whatever is apropos for your setup), and then let the NSTextView manage the 
content until editing has been committed, at which time you pull the plain 
string out and set your model property.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Checkbox Mayhem

2016-12-18 Thread Keary Suska

> On Dec 18, 2016, at 5:50 AM, Frank D. Engel, Jr. <fde...@fjrhome.net> wrote:
> 
> My guess is that for some reason the @synthesize methods are not calling 
> "willChangeValueForKey" and the like - why would that be the case?  I have 
> worked on one or two other Core Data projects and I don't remember having to 
> do this before...

With Core Data, you don’t use @synthesize, you use @dynamic. @synthesize will 
not create Core Data-friendly accessors. @dynamic allows the Core Data runtime 
to create the appropriate accessors for you.

Also, in the future, please don’t just say “they aren’t being saved”, even with 
“not using X or Y”. Say exactly how you are persisting as there are at least 
four common persistence methods (Archiving, User Defaults, Document-based, Core 
Data).

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Releasing properties?

2016-08-27 Thread Keary Suska

> On Aug 27, 2016, at 8:22 AM, じょいすじょん <dangerwillrobinsondan...@gmail.com> 
> wrote:
> 
> 
>> On 2016 Aug 27, at 23:09, Keary Suska <cocoa-...@esoteritech.com> wrote:
>> 
>>> 
>>> On Aug 27, 2016, at 5:22 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
>>> wrote:
>>> 
>>> Consider the following example properties:
>>> 
>>>   NSApplication: @property(strong) NSMenu *mainMenu
>>>   NSFont: @property(readonly, copy) NSString *familyName
>>>   NSColorPanel: @property(copy) NSColor *color
>>> 
>>> AFAIU I must not release the NSMenu/NSString/NSColor obtained from these
>>> properties because I don't own the objects returned by those properties and
>>> Apple's memory management policy docs clearly say:
>>> 
>>>   "You must not relinquish ownership of an object you do not own"
>>> 
>>> So I think I've got that right but I'd be glad if somebody could just
>>> confirm that I got it right ;)
>>> 
>>> I'm just a little confused because of the keywords "strong" and "copy" in
>>> the @property declarations but AFAIU these only refer to setting those
>>> properties, not getting those properties, i.e. the object is copied when
>>> *setting* the property, not when *getting* it. Right?
>>> 
>>> And another question: Can it also happen that a class has a property
>>> which returns an object which I *must* release or is it a general rule
>>> that getting a @property always returns objects which I do not own
>>> and hence mustn't released?
>> 
>> There are only specific method conventions that establish ownership: 
>> alloc+init and new. This is because ownership should only be granted when 
>> specifically requested by the caller. There is no good reason for an object 
>> to require that a caller own a returned object. Now, some API could decide 
>> to buck the convention and have a different object construction naming, but 
>> the point is the same. If an API does anything else, it is badly designed. 
>> Cocoa will never do this.
>> 
>> One could even argue (and some have) that there is no good reason for *any* 
>> object method to return a retained object, as that forces the caller to 
>> explicitly require ownership. And that is key: ownership is a function of 
>> the caller, not the object.
>> 
>> HTH,
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>> 
> Just to keep everyone on the rules, I'm going to post the docs links.
> It's too easy to quote it wrong. (not saying anybody did)
> 
> Objective-C
> 
> https://developer.apple.com/library/mac/documentation/General/Conceptual/DevPedia-CocoaCore/MemoryManagement.html
> 
> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html
> 
> Core Foundation (because you WILL use it at some point)
> 
> https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html

Doh! Forgot “copy”. Best to point to docs since they are clear and succinct.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Releasing properties?

2016-08-27 Thread Keary Suska

> On Aug 27, 2016, at 5:22 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:
> 
> Consider the following example properties:
> 
>NSApplication: @property(strong) NSMenu *mainMenu
>NSFont: @property(readonly, copy) NSString *familyName
>NSColorPanel: @property(copy) NSColor *color
> 
> AFAIU I must not release the NSMenu/NSString/NSColor obtained from these
> properties because I don't own the objects returned by those properties and
> Apple's memory management policy docs clearly say:
> 
>"You must not relinquish ownership of an object you do not own"
> 
> So I think I've got that right but I'd be glad if somebody could just
> confirm that I got it right ;)
> 
> I'm just a little confused because of the keywords "strong" and "copy" in
> the @property declarations but AFAIU these only refer to setting those
> properties, not getting those properties, i.e. the object is copied when
> *setting* the property, not when *getting* it. Right?
> 
> And another question: Can it also happen that a class has a property
> which returns an object which I *must* release or is it a general rule
> that getting a @property always returns objects which I do not own
> and hence mustn't released?

There are only specific method conventions that establish ownership: alloc+init 
and new. This is because ownership should only be granted when specifically 
requested by the caller. There is no good reason for an object to require that 
a caller own a returned object. Now, some API could decide to buck the 
convention and have a different object construction naming, but the point is 
the same. If an API does anything else, it is badly designed. Cocoa will never 
do this.

One could even argue (and some have) that there is no good reason for *any* 
object method to return a retained object, as that forces the caller to 
explicitly require ownership. And that is key: ownership is a function of the 
caller, not the object.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: runModalForWindow() doesn't re-activate former window upon return

2016-08-26 Thread Keary Suska

> On Aug 26, 2016, at 8:36 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:
> 
> Thanks, that's what I was looking for. I just wish such essential information 
> wouldn't
> be hidden in the accompanying documentation. This should really be mentioned 
> in the
> documentation of runModalForWindow() or stopModal()/stopModalWithCode() IMHO. 
> Here
> it is again:
> 
> "It is important to call orderOut: when finished with your dialog, or it is 
> not removed
> from the screen."

Apple used to cross reference the documentation, but apparently do not anymore. 
May be worth filing a radar on the subject. In any case, you will miss large 
chunks of necessary information if you only refer to the class documentation. 
The “programming topics” docs are required reading.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: runModalForWindow() doesn't re-activate former window upon return

2016-08-26 Thread Keary Suska

> On Aug 25, 2016, at 12:51 PM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:
> 
>> What happens if you add -orderOut: to the button action method?
> 
> Ok, this solves the problem. But still, shouldn't this be handled 
> automatically
> by runModalForWindow()? Why does it activate a window that doesn't belong to
> my application when it returns? That doesn't look reasonable to me at all...

Apparently not:

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingAppModalDialogs.html

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: runModalForWindow() doesn't re-activate former window upon return

2016-08-25 Thread Keary Suska

> On Aug 25, 2016, at 9:45 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
> wrote:
> 
> Tested it, the window is clearly main and key, this is the debug output:
> 
> CHECK: 0x10040b4d0 0x10040b4d0 0x10040b4d0
> 
> i.e. [NSApp mainWindow], [NSApp keyWindow] and my NSWindow pointer are
> exactly the same before runModalForWindow() is called.

What are they *after* the modal loop has ended? What happens if you add 
-orderOut: to the button action method?

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Need some NSComboBox debugging help

2016-08-05 Thread Keary Suska

> On Aug 4, 2016, at 11:34 PM, livinginlosange...@mac.com wrote:
> 
> I have 8 NSComboBoxes in my application organzied into 4 pairs, each pair 
> sharing an NSComboBox delegate. I have had some users periodically say that 
> the combo-boxes get confused. ComboBox A will wrongly display ComboBox B’s 
> data. I have scoured my code for an places where I might perform an 
> assignment as opposed to performing an equality comparison. I have a hard 
> recreating this event. More often than not, I experience my combo boxes not 
> working. I’ll restart and everything will be fine. Not be able to repeat the 
> issue is the biggest problem.  
> 
> My next step to solve this issue will be to catch the popupwillopen 
> notifications so I can re-set the delegate.
> 
> Does anyone have any ideas on how to solve this issue?

There is not much anyone can help without seeing code. One would think that it 
either has to do with the assignment of the delegate or the assignment of the 
outlets/properties of the delegate, or both. Could be a memory issue, which 
makes more sense for crashes, but is one way objects can trade places.

I would log every delegate assignment and outlet/property assignment, as well 
as every time each object in question is created and destroyed to see if the 
object addresses stay consistent or change when there is some event (like the 
crashes you experience). I would also make sure to set the delegate to nil when 
you expect the delegate to be destroyed, and outlets/properties of combo boxes 
to nil when they are expected to be destroyed.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: NSTableView Drag/Drop - Which Column?

2016-07-23 Thread Keary Suska

> On Jul 23, 2016, at 6:53 AM, Frank D. Engel, Jr. <fde...@fjrhome.net> wrote:
> 
> Does anyone know if there is a way to determine which column of an 
> NSTableView something being dragged is dropped onto?
> 
> I have drag and drop from one table in my application onto a row of another 
> table working, but I would like to know which column of the destination table 
> the source item was released on so that I can have different behavior 
> depending on which column received the object.
> 
> The destination table is view-based if that makes a difference.

In your drag operation method have you tried calling [NSEvent mouseLocation] 
and then using -columnAtPoint: to determine which column the pointer is at? 
Noting that +mouseLocation provides screen coordinates, so they will need to be 
converted.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Keary Suska

> On Jul 5, 2016, at 5:36 AM, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
> wrote:
> 
> I have a problem with property synthesis in my code, which I hope somebody 
> can advise on. I find I have to write different property synthesis code for 
> 32- or 64-bit builds in order to avoid compiler errors.
> 
> A minimal demonstration of the problem can be found below - build as part of 
> a fresh project on Xcode 5 or 6, with ARC disabled. It surprises me that I 
> have to write different synthesis code for 32- or 64-bit builds - and this 
> then makes me worry that I am doing something more fundamentally wrong. Can 
> anyone comment (or explain)?
> 
> [I appreciate that this code may be old-fashioned in style - I am not even 
> sure what is or is not the recommended style these days. It seems to work 
> though - and, importantly, as far as I can tell the synthesized property 
> myFlag on MutableSettings *does* map to the same backing variable, even on a 
> 64-bit build where I am not able to specify the backing variable in the 
> synthesis statement]

32 vs 64 is likely coincidental, and probably has more to do with compiler 
differences. I.e., at that time, there were additional compiler “features” for 
64 bit vs 32 bit. So my thought is that what you are doing is wrong in both 
cases, but you are simply getting different compiler errors.

The essential issue I believe is that you cannot re-synthesize in a subclass. 
You will have to specify the setter explicitly. The issue in the second 
(64-bit) case is that when you specify @synthesize with an instance variable 
you are specifying a *new* instance variable on that class, but the compiler 
correctly warns you that that instance variable has already been defined in the 
superclass and therefore cannot also be defined in the subclass. The 32 bit 
compiler seems to be letting you get away with this error, but it could have 
horrible unintended consequences.

> @interface ImmutableSettings : NSObject
> {
>BOOL_myFlag;
> }
> @property (readonly) BOOL myFlag;
> @end
> 
> @interface MutableSettings : ImmutableSettings
> @property (readwrite) BOOL myFlag;
> @end
> 
> @implementation ImmutableSettings
> 
> -(id)init
> {
>if (!(self = [super init]))
>return nil;
>_myFlag = true;
>return self;
> }
> @synthesize myFlag = _myFlag;
> 
> @end
> 
> @implementation MutableSettings
> // This is very odd - I get errors on 64-bit builds if I specify a backing 
> variable for synthesis,
> // but I get errors on 32-bit builds if I *don't* specify a backing variable!?
> #if defined(__x86_64__)
>// On 32-bit builds I get an error here:
>// "Synthesized property 'myFlag' must either be named the same as a 
> compatible instance variable or must explicitly name an instance variable"
>@synthesize myFlag;
> #else
>// On 64-bit builds I get an error here:
>    // "Property 'myFlag' attempting to use instance variable '_myFlag' 
> declared in super class 'ImmutableSettings'"
>@synthesize myFlag = _myFlag;
> #endif

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Security with Streams

2016-06-26 Thread Keary Suska

> On Jun 26, 2016, at 9:13 PM, Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
> 
>> 
>> 
>> Self-signed certificates can only offer encryption, but cannot offer trust 
>> because they are not verifiable. You can’t use the server certificate as a 
>> key since you pass that key out to anyone who wants it (in your app), and 
>> anyone who gets it can impersonate the server.
> 
> Assume that an evil entity has got hold of “MyServerCertificate.cer”, but has 
> no access to my keychain and thus to the private key of MyServerCertificate. 
> Could they use this certificate to open a secure stream to a client? Or do 
> they need the private key to sign?

To clarify, I was pointing out two weaknesses that come out of self-signed 
certificates, and in the latter case how comparing an embedded certificate/key 
with the server’s public certificate/key would not offer any security if it 
were self-signed, as you would be using the cert as a passcode that anyone can 
easily have. With a verifiable certificate you wouldn’t normally have these 
weaknesses and you get server verification (usually called “authentication”) as 
part of the SSL/TLS protocol so you don’t have to code for that case (though 
you may need to be explicit that you want certificate verification if it isn’t 
the default).

For the latter part of the question, in asymmetric encryption schemes, the 
private key is certainly needed to decrypt but does not authenticate. If you 
permit ad-hoc connections from the server to the client, the only way to 
authenticate the server would be by the server providing a client certificate 
and that being verified by a third-party. Even a self-signed client certificate 
does not provide authentication as it too is tantamount to using the 
certificate as a password that you give you to anyone who buys your app. Now, 
normally, the communications would still be encrypted and difficult to 
decipher, as long as you are comparing signed certificates, but if the 
certificate ever changes you now have to redistribute the new signed 
certificate.

I would also reiterate that when using SSL/TLS you don’t need to bother with 
key verification such as what ssh uses, since ssh uses those methods precisely 
because it does not rely on third party authentication so requires the client 
and server to agree that the connection is valid even though neither can 
actually guarantee that it is the case. This would be more similar to my 
peer-to-peer example, where trust is agreed upon before communication proceeds. 
SSL/TLS is also more robust in this case because the certificate can change at 
any time (which will periodically happen every 1-5 years anyway) but the server 
can still be correctly authenticated.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Security with Streams

2016-06-26 Thread Keary Suska

> On Jun 25, 2016, at 8:44 PM, Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
> 
> Following TN2326 I created a (self signed) Certificate Authority and a 
> Digital Identity called "MyServerId".
> 


>> We are now falling into the rabbit hole that is peer-to-peer trust & 
>> identity. How is your server going to identify it so that a client will know 
>> that it’s the server it expects? I don’t know whether you’ve given any 
>> thought to this; the answer affects how you’d implement this part of the app.
> 
> I have thought about this, but I am not at all sure that my thoughts are 
> correct.
> Currently (as indicated in the code above) my client has a copy of the real 
> server certificate and compares it with the certificate obtained from its 
> inputStream.
> I am not sure whether putting the server certificate into the client is ok or 
> a breach of security. 
> 
> That is: the client will accept any server which has signed with the server 
> certificate.

Self-signed certificates can only offer encryption, but cannot offer trust 
because they are not verifiable. You can’t use the server certificate as a key 
since you pass that key out to anyone who wants it (in your app), and anyone 
who gets it can impersonate the server.

I am unclear to me whether you are after a client-server (i.e. all servers are 
under your control) or peer-to-peer (i.e. every client is a server and every 
server is a client)) model? With the former everything you need other than 
client verification is inherent in the SSL/TLS protocol (if you use managed and 
verifiable certificates). With the latter, SSL/TLS will not likely serve you as 
to do it correctly will likely be cost prohibitive (unless you can pass that 
cost to the consumer in some way).

That being said, in a peer-to-peer model I would (OTOH) use a public 
key/private key setup, where public keys are swapped and maintained in a trust 
database once a “trust” connection has been made. Pairing a bluetooth keyboard 
is a simple example of how to establish an initial “trust” connection. The 
benefit here is that by encrypting messages with a user’s public key, only the 
designated user can decrypt it, so you get both internal and external security. 
If a customer asks, “how do I know I am talking to whom I think?” You say, “It 
doesn’t matter, because what they get will not be decipherable unless they are 
who they say they are.” This can be followed up with the fact that all 
electronic communications are intercept-able, so the approach is to make the 
information as undecipherable as possible since there is no way to prevent 
interception.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Selected value binding in popups

2016-06-16 Thread Keary Suska

> On Jun 15, 2016, at 10:15 PM, Rick Mann <rm...@latencyzero.com> wrote:
> 
> I have a popup menu that's bound to an NSArrayController of AVCaptureDevice 
> objects. These objects have a "localizedName" property that I use for the 
> content values, and the content and content objects point to the 
> NSArrayController.
> 
> I also have a property on my view controller used for the selected object.
> 
> The problem comes when I re-build the array of objects that backs the 
> NSArrayController (in the case where the selected device disappears): I 
> assign a new array to the property, and the selected item in the popup menu 
> changes to be the object description for the AVCaptureDevice object still in 
> the selected property.
> 
> IB doesn't let me bind to selected value when I'm binding to selected object. 
> Is there anything I can do here?

IIRC, this is what happens when the selected object doesn’t exist in the 
content array (or for whatever reason cannot be found by the API). Are you 
simply modifying the content array (adding/removing), or re-creating objects?

In any case, you might have better results using KVC-compliat mutator methods 
on the content array rather than replacing it entirely.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Bind NSTableView to array of dictionaries in user defaults

2016-05-06 Thread Keary Suska

> On May 5, 2016, at 7:47 PM, Jerry Krinock <je...@ieee.org> wrote:
> 
> After reading Quincey’s reply, I had concluded that this is one of those 
> cases where Cocoa Bindings requires additional “glue”, which defeats one of 
> the two purposes of Cocoa Bindings.  But it would be very cool if there were 
> some configuration change that would be make this work in both directions.  
> It seems like we’re really close.
> 
> I’m accustomed to doing this kind of code-less binding to a Core Data model, 
> wherein it “just works”.  That’s not surprising, because of course Core Data 
> knows the data model in great detail.  It can observe everything.

Trying out your example it looks like both you and Quincey may be correct, but 
on the opposite ends. The issue appears to be something with how view-based 
tables work, rather than NSArrayController. If you substitute with a cell-based 
table, it works flawlessly. The issue seems to involve binding through 
objectValue, so I guess you are back to needing some kind of glue code.

I was able to get it to work properly by proxy-ing the array in the app 
delegate, so this must specifically be an interaction between view-based tables 
and NSUserDefaultsController. I would file a radar, FWIW.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Bind NSTableView to array of dictionaries in user defaults

2016-05-05 Thread Keary Suska

> On May 5, 2016, at 7:44 AM, Jerry Krinock <je...@ieee.org> wrote:
> 
> In an OS X app, I wanted to bind a table of objects, each represented by a 
> dictionary, to an array of dictionaries in user defaults.
> 
> So I bound the Content Array of the array controller to the 'values' of the 
> shared user defaults controller with an arbitrary key path, which pleasantly 
> became the key to the array in the user defaults.  I set "Handles Content as 
> Compound Values” to ON.

Is this a single or multi-level keypath? IIRC the issues Quincy is referring to 
are common in a multiple-object keypath, especially for defaults as 
NSUserDefaultsController uses some internal trickery to edit the immutable 
collections maintained by NSUserDefaults.

> Result: The table is populated as expected from user defaults when its window 
> opens, and all works and persists as expected if user adds or deletes an 
> object (row).  But changes to object attributes are persisted only for new 
> objects, and only if user adds *another* object before quitting.

I cannot replicate this behavior with a straightforward approach. Can you 
create a reduction that replicates the behavior?

> In the array controller's content, the object attribute is always changed as 
> expected.  So, the problem is the binding of the array controller content to 
> user defaults, and I think the explanation is that, as always, KVO is 
> “shallow”.  Observing an array does not observe changes to its elements.

This is curious—how do you know that the attribute is being changed as 
expected? Is it that it shows in the UI, but is not persisted? Have you changed 
the default value of -[NSUserDefaultsController  appliesImmediately]?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Triggering UITableView's -didSelectRowAtIndexPath: delegate callback

2016-02-29 Thread Keary Suska

> On Feb 28, 2016, at 11:05 PM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>>> On Feb 27, 2016, at 4:27 PM, Keary Suska 
>>> <cocoa-...@esoteritech.com<mailto:cocoa-...@esoteritech.com>> wrote:
>>> 
>>>  This results in a much more reliable and extensible decoupling since no 
>>> other object should know those internal signaling mechanics and should have 
>>> confidence that any other object interested in the selection will be 
>>> dutifully notified. In fact, this is how NSTableView works. Why UITableView 
>>> doesn’t, seems worthy of a radar.
> 
> NSTableView doesn’t work that way. Changing the selection programmatically 
> does not trigger a selection-changed notification / delegate callback.

That does appear to be the case, at least almost entirely. I was 
mis-remembering as curiously, -tableViewSelectionDidChange: is always sent, 
perhaps simply a side effect to the promise of notifications, but in contrast 
-tableViewSelectionIsChanging: is not. Looking at my older code I did notice 
that I needed to work around -selectionShouldChangeInTableView: not being 
called when I hoped it would.

I stand by my assertion that delegate methods should always be called 
regardless of whether the triggering event is from the UI or programmatically, 
and that the fact they don’t has nothing to do with decoupling but instead an 
implementation decision.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: windowDidLoad getting called twice?

2016-02-28 Thread Keary Suska

> On Feb 28, 2016, at 8:10 AM, Dave <d...@looktowindward.com> wrote:
> 
> the winddowDidLoad method of my Window Controller is getting called twice. Is 
> this expected behaviour? The window is the NIB has no views setup in the 
> window ContentView, I add them after the window NIB has loaded. I’m guessing 
> the second call is when I add subviews to the Content View…..

As I understand, no. No need to guess—set a break point and know.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Triggering UITableView's -didSelectRowAtIndexPath: delegate callback

2016-02-27 Thread Keary Suska

> On Feb 27, 2016, at 3:59 PM, Ben Kennedy <b...@zygoat.ca> wrote:
> 
> 
>> On 27 Feb 2016, at 11:17 am, Carl Hoefs <newsli...@autonomy.caltech.edu> 
>> wrote:
>> 
>> Yes, that works, thanks! I just thought there might be a "preferred" way to 
>> do it. I guess I was hoping for something like:
>> 
>> [myTableView selectRowAtIndexPath:indexPath 
>>animated:YES 
>>  scrollPosition:UITableViewScrollPositionMiddle
>>triggersDelegateCallback:YES];
> 
> What gain would that afford you, though?
> 
> I believe that the table view API is designed this way to afford the 
> programmer control and flexibility. Perhaps your didSelectRow:... 
> implementation calls some private method to do the business logic, say -[self 
> fireTheRockets]. In that case, you could simply call fireTheRockets directly 
> here instead.
> 
> By contrast, the delegate API provides your code a means to act on external 
> events (user input) brokered by the table view. Perhaps in such a case there 
> is additional UI-related work not suitable for inclusion in fireTheRockets.
> 
> This decoupling enables you to separate these concerns.
> 

Except that it doesn’t follow. There is no design necessity that the object 
programmatically setting the selection is the same object as the delegate, nor 
that those two objects know anything about each other. Also if a delegate 
implements such a delegate call it is signaling that it needs to know every 
selection change regardless of how it is accomplished (since it has not way of 
knowing in advance how it was accomplished, unless you decide to couple the two 
objects). This results in a much more reliable and extensible decoupling since 
no other object should know those internal signaling mechanics and should have 
confidence that any other object interested in the selection will be dutifully 
notified. In fact, this is how NSTableView works. Why UITableView doesn’t, 
seems worthy of a radar.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Archive/Unarchive Problem - Bug in MacOSX/Cocoa?

2016-02-05 Thread Keary Suska

> On Feb 5, 2016, at 8:45 AM, Dave <d...@looktowindward.com> wrote:
> 
> Hi All,
> 
> I have written a Test App that demonstrates the problem, please let me know 
> if you’d like a copy.
> 
> I’m not sure if its a bug or not and if not a bug then how to make it work. 
> Everyone keeps telling me its possible but no one seems to know how to make 
> it work.
> 
> According to the (few) docs I found on it, its possible too, but again it 
> doesn’t actually tell you how to do it.
> 
> I’ll use up a DTS incident on this but they will take forever to respond and 
> I jwish I knew for certain whether this is *SUPPOSED* to work or not. It 
> doesn’t actually say in black and white one way or the other.

I would like to see a copy, as I am curious why it isn’t working. The issue 
isn’t that no-one knows how, it is that it is simply supposed to work. There 
shouldn’t be anything you need to do to encode a complex graph.

However, I can see that *decoding* the graph could be difficult. The decoding 
of any single object happens in the -initWithCoder: implementation of that 
object. One would think that until that method is exited, NSCoder cannot know 
that the object exists. Therefore If any of its child objects reference it, how 
can the coder know which object to use? I don’t know how, or if, 
NSKeyedUnarchiver handles this situation.

You may have to handle it yourself—i.e. do not encode “parent” properties and 
instead set the property value in the parents’ -initWithCoder:.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: Easier way to make NSView subclasses refresh on a property change?

2016-02-03 Thread Keary Suska

> On Feb 2, 2016, at 11:05 PM, Graham Cox <graham@bigpond.com> wrote:
> 
> Hi all,
> 
> Whenever I make a custom view class, it often has a bunch of properties that 
> affect the content it renders. So, for each setter that does this, I have to 
> override the setter, do whatever it normally does plus call 
> -setNeedsDisplay:YES.
> 
> This gets tedious.
> 
> Is there a good way to automate this for a given set of properties? I 
> considered overriding -didChangeValueForKey: and checking the key against a 
> set of exported property names, and that would work, except all my custom 
> views would then need to subclass this one special kind of view instead of 
> NSView. Can it be done with a standard NSView? (MacOS)
> 
> A similar requirement applies to CALayer too.

I have had an analogous situation, and my solution, however kludgey, was to 
have a single property, say a BOOL “refresh”, observe that property, and then 
use +keyPathForValuesAffectingKey to notify the observer. In your case the 
observer would call setNeedsDisplay: or whatever was needed.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: NSTableView: Rows from bottom up

2015-08-31 Thread Keary Suska
On Aug 31, 2015, at 7:51 PM, Eric Gorr <mail...@ericgorr.net> wrote:
> 
> Normally when one adds the first row to a NSTableView, it will appear at the 
> top of the view and additional rows will appear below it. Is it possible to 
> have the first row appear at the bottom of the NSTableView and for new rows 
> to appear above it?
> 
> No doubt this would require some extensive customization. I am open to 
> alternative solutions, but the one invariant will remain…first row at the 
> bottom and additional rows appearing above.
> 
> I could fake it by creating a large enough number of rows so the view is 
> filled and setting the scroll position to the bottom, but I find that to be a 
> bit inelegant…although, I would go that route before doing something 
> completely custom.
> 
> If you are wondering why someone might need such a thing, consider the case 
> of a calculator where the most common way to view the numbers (at least for 
> RPN entry) is for the most recent entry or calculation is to appear at the 
> bottom and previous entries to appear above it.

Unless something changed before I used it last, the insert location will depend 
on how you add an object, i.e. -add: vs -insert:, as well as any sorting 
settings. Using -add: should always append to the end of the collection as long 
as it is unsorted or does not re-sort automatically. If you use your own method 
to add new objects, you can do whatever you want. No need to customize much.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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: NSUndoManager.prepareWithInvocationTarget:

2015-05-10 Thread Keary Suska
On May 10, 2015, at 7:07 AM, Charles Jenkins cejw...@gmail.com wrote:

 Am I correct to believe there is NO way to use 
 NSUndoManager.prepareWithInvocationTarget: if your undo method requires a 
 parameter?
 
 I can use any method I want which has no parameter, but any method with 
 parameters gets me the error “AnyObject does not have member named…”
 
 I thought about making a ClosureWrapper object which could have a 
 parameterless method to call any method on a captured object, but since the 
 invocation holds a weak reference, I think any instance of ClosureWrapper 
 would be destroyed immediately after registration, so I didn’t bother trying.
 
 Right now I’m sticking with registerUndoWithTarget:selector:object:, but I’d 
 like to know if there is a good way to use prepareWithInvocationTarget: 
 instead.

As was indicated, -prepareWithInvocationTarget: is the precise method used 
anytime you have a single non-object parameter or multiple parameters. Chances 
are, the error that you are experiencing is due to stringing a bunch of 
selectors together with the period operator, which doesn't always work as you 
expect. In particular, although I am not up to date with compilers, I am pretty 
sure you (still) cannot use dot notation to invoke methods that take 
parameters, so you must use bracket syntax: [NSUndoManager 
prepareWithInvocationTarget: aTarget]

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: setting table view rows and columns?

2015-03-13 Thread Keary Suska

On Mar 13, 2015, at 1:29 AM, Steve Mills sjmi...@mac.com wrote:

 On Mar 13, 2015, at 02:18:00, Patrick J. Collins 
 patr...@collinatorstudios.com wrote:
 
 The inspector shows the text set under 'Title', yet when I build, there
 is no text.. it's all blank..  Quite frustrating.
 
 You're sure you have an NSTableColumn selected, not Table View Cell that's in 
 the column? Both have a Title field in the inspector.

Also make sure that that headers is checked in the table view attributes 
inspector, or the headers won't be exposed to set in the first place.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: removeObserver:forKeyPath:context: fails; but removeObserver:forKeyPath: works?!

2015-03-10 Thread Keary Suska
On Mar 10, 2015, at 11:50 AM, Sean McBride s...@rogue-research.com wrote:

 Hi all,
 
 Can anyone think of a sitation where using removeObserver:forKeyPath: works 
 correctly, then modernizing the code to use 
 removeObserver:forKeyPath:context: breaks things?
 
 Long story: I have a custom NSView subclass that exposes a custom binding.  
 In bind: it does addObserver:forKeyPath:options:context:.  In unbind: it does 
 removeObserver:forKeyPath:.  If I update unbind: to use the 'context' version 
 it breaks.
 
 Specifically, if I have several of these views onscreen (all bound to the 
 same NSObjectController) then remove all but one of the views from the view 
 hierarchy, the remaining one no longer receives any KVO notifications.  I've 
 put logs everywhere, and subclassed NSObjectController and implemented 
 addremoveObserver methods to log and call super.  All the log output is the 
 same in the working  broken cases except the deliberate difference between 
 using removeObserver: with or without the context.  I am surprised to see 
 this backtrace however:
 
 -[MyObjectController removeObserver:forKeyPath:]
 -[NSObject(NSKeyValueObserverRegistration) 
 removeObserver:forKeyPath:context:] ()
 -[NSController removeObserver:forKeyPath:context:] ()
 -[MyObjectController removeObserver:forKeyPath:context:]
 -[MyView unbind:]
 ...
 
 Odd that NSObjectController removeObserver:forKeyPath:context: calls 
 removeObserver:forKeyPath:, no?
 
 Any clues would help... :)

Have you checked observationInfo at each point to ensure that observation is 
being added/removed exactly as you expect?

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Create a NSURL as a way to validate urls - not working

2015-03-02 Thread Keary Suska
On Mar 2, 2015, at 4:55 PM, Juanjo Conti jjco...@carouselapps.com wrote:

 Ok, I wanted to validate that the url is an absolute one. Is there
 something in Swift standard lib to do this?

That depends on what you mean by validate. If you simply mean checking 
whether it well-formed, you can do that easily with a regular expression match, 
such as (written in email):
^http://(?:[a-z0-9-]+\.){1,}[a-z]{2,4}

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Inconvenient exception impossible to get rid of?

2015-03-02 Thread Keary Suska
On Mar 2, 2015, at 4:14 PM, Graham Cox graham@bigpond.com wrote:

 I'm getting an exception thrown by the NSPopover code when a popover is going 
 away. Due to the way popovers are handled, the exception is not one I'm able 
 to catch, so the app is terminated. This is a very big punishment for what 
 seems a trivial transgression that doesn't even matter at this time, nor one 
 I have any apparent control over.
 
 Here's the upper part of the stack trace of the exception:
 
 2015-03-03 09:59:07.164 LogicBoard[44305:3418051] *** Terminating app due to 
 uncaught exception 'NSInternalInconsistencyException', reason: 'The 
 contentViewController ((null)) or contentViewController.view is nil.'
 *** First throw call stack:
 (
   0   CoreFoundation  0x7fff90bdc66c 
 __exceptionPreprocess + 172
   1   libobjc.A.dylib 0x7fff869f776e 
 objc_exception_throw + 43
   2   CoreFoundation  0x7fff90bdc51d 
 +[NSException raise:format:] + 205
   3   AppKit  0x7fff8958e89d -[NSPopover 
 showRelativeToRect:ofView:preferredEdge:] + 249
   4   AppKit  0x7fff89bff304 
 __53-[NSPopover showRelativeToRect:ofView:preferredEdge:]_block_invoke + 94
   5   AppKit  0x7fff895ac6aa -[NSPopover 
 _executeClosingBlock] + 31
   6   AppKit  0x7fff895ac517 -[NSPopover 
 _finishClosingAndShouldNotify:] + 197
   7   AppKit  0x7fff89491204 -[NSWindow 
 _windowTransformAnimationDidEnd:] + 380
   8   libdispatch.dylib   0x00010025c2bb 
 _dispatch_call_block_and_release + 12
   9   libdispatch.dylib   0x000100256d43 
 _dispatch_client_callout + 8
   10  libdispatch.dylib   0x000100265d9f 
 _dispatch_main_queue_callback_4CF + 1370
   11  CoreFoundation  0x7fff90b2fc79 
 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
   12  CoreFoundation  0x7fff90aec30f 
 __CFRunLoopRun + 2159
 
 
 What it's complaining about is that the viewController, or its view, is nil. 
 The thing is, I do supply this controller and the view is there - in fact 
 it's been successfully displayed, interacted with and dismissed by this point 
 - this stack trace is the result of dismissing the popover after I'm done 
 with it. At this time, it shouldn't care whether it has a view controller or 
 a view - presumably it will release the view controller it holds anyway at 
 this time, so it appears as if the exception is completely spurious.
 
 This is happening on 10.10. It's been a while since I worked on this code, 
 last time was under 10.8, and I don't recall that I was getting this 
 exception in the same situation there.
 
 This is the code that displays the popover. It's not very interesting, and 
 the try/catch block here doesn't trap the above exception, because it's 
 actually nothing to do with it, even though at first glance it appears to be 
 thrown by the same function.
 
 - (void)  displayPopoverForDeviceLayer:(LB_DeviceLayer*) dvl
 {
   NSRect popRect = dvl.frame;
   NSViewController* devViewController = [dvl 
 viewControllerForAuxiliaryContent];
   
   if( devViewController )
   {
   self.auxiliaryContentPopover.contentViewController = 
 devViewController;
   self.auxiliaryContentPopover.behavior = 
 NSPopoverBehaviorSemitransient;
   
   NSView* contentView = devViewController.view;
   
   NSAssert( contentView, @no view supplied by controller);  
 // never asserts, there is always a controller and view here
   
   self.auxiliaryContentPopover.contentSize = 
 contentView.frame.size;
   
   @try
   {
   [self.auxiliaryContentPopover 
 showRelativeToRect:popRect ofView:self preferredEdge:NSMaxXEdge];
   }
   @catch (NSException *exception)
   {
   NSLog(@huh?!); // never invoked
   }
   }
 }
 
 Is this just a case of the popover code on 10.10 being over-zealous about 
 asserting that it has a controller, even though it doesn't need one once the 
 popover is dismissed?
 
 I'm at a loss as to how to sort this problem out - the closure block for the 
 popover is invoked automatically, not by my code, so I'm not seeing any way 
 to fix this.

Maybe it wants the view around for some closing animation. Does making animates 
NO change anything? Also, are you really unable to keep the view or view 
controller around until the popover is completely closed (maybe 
NSPopoverDidCloseNotification, but I can't day for sure).

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

Re: -beginSheet:modalForWindow:modalDelegate:didEndSelector

2015-02-20 Thread Keary Suska

On Feb 20, 2015, at 1:34 PM, Raglan T. Tiger r...@crusaderrabbit.net wrote:

 2015-02-20 13:17:57.666 [5613:177188] aboutWindowController 
 ETAboutWindowController: 0x600e4600
 2015-02-20 13:17:57.666 [5613:177188] aboutWindowController window NSWindow: 
 0x601e9500
 2015-02-20 13:17:57.666 [5613:177188] mainWindow window NSWindow: 
 0x601e9500
 
 You can see that as Steve asked the main window and sheet window are the same.

This would be disconcerting to me--I didn't think that a window could be the 
main window without actually being open, which means that the window is already 
open before beginSheet... is called. Anotehr checkbox to check: is restorable 
unchecked? If not, the system may be trying to restore your sheet as a regular 
window and something is getting bunged up.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: -beginSheet:modalForWindow:modalDelegate:didEndSelector

2015-02-20 Thread Keary Suska
On Feb 20, 2015, at 12:35 PM, Raglan T. Tiger r...@crusaderrabbit.net wrote:

 
 On Feb 20, 2015, at 12:27 PM, Steve Mills sjmi...@mac.com wrote:
 
 Also ensure that the Title Bar attribute is turned on.
 
 Under Appearance Title Bar and Shadow are selected.

Does [NSApp mainWindow] return a non-nil value at the point the code is invoked?

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Detecting Managed Object Property Change From Undo Redo

2015-01-27 Thread Keary Suska
On Jan 27, 2015, at 9:52 AM, Jerry Krinock je...@ieee.org wrote:

 
 On 2015 Jan 27, at 06:46, Keary Suska cocoa-...@esoteritech.com wrote:
 
 Better, however, to have a property declaration, which would also synthesize 
 an ivar in modern LLVMs (as of Xcode 5?).
 
 You mean the property declaration would synthesize the ivar.  I didn’t try 
 that.  I agree it would be better.

I should clarify that an ivar may not be synthesized if @dynamic is used. I 
forget what the current implementation does for CD, which is a special case. 
Specifying an ivar is probably the best and easiest approach.

 If we stop and think a moment, why would calling super ever work? This is 
 still Objective-C, and calling super is only valid when the class' 
 superclass implements the method. And I bet NSManagedObject doesn't…
 
 Indeed, it crashed when I invoked it.

Also, more specifically, it is not an override but specifying an implementation 
that, if not provided, will be provided at run-time.

 Primitive methods … There is absolutely nothing magical about them, because 
 they need to be entirely un-magical to escape CD's notice.
 
 
 Therefore it is really hard to break anything unless you deliberately do so 
 (or deliberately ignore compiler warnings).
 
 I don’t think it warned me about defining a primitive setter without a 
 primitive getter, although it might have because I tried it in a project that 
 is currently giving me 60 warnings due to major work in progress

What exactly happened when you specified the setter, but not the getter? That 
part of the conversation was private between you and Quincey. I am simply 
curious as I can't imagine why one would want to. I would have thought that the 
runtime would have happily provided its own implementation, but since it would 
use the internal store and not the ivar the values won't match. I imagine some 
sort of inconsistency exception could happen...

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Detecting Managed Object Property Change From Undo Redo

2015-01-27 Thread Keary Suska
 What in the world is that nonCompliantKVCivar?  I tried it in my project, on 
 the ‘rating’ property as in my YouTube video.
 
 - (void)setPrimitiveRating:(NSNumber*)newRating {
rating = newRating ;
 }
 
 Does not compile.  The compiler never heard of ‘rating’.  Same result if I 
 change it to _rating, m_rating or nonCompliantKVCrating.  OK, so then I added 
 an ivar: _rating, and now of course
   _rating = newRating ;
 compiles.

Remember that the compiler can't know anything about your model as all of that 
is specified at runtime. I wouldn't have expected CD to be smart enough to 
match up to a simply ivar declaration but it makes sense. Better, however, to 
have a property declaration, which would also synthesize an ivar in modern 
LLVMs (as of Xcode 5?).

 It still persists!

It will if you modeled it, which I didn't notice, but must be the case. It 
won't if you simply define an ivar or a property on your class and implement 
the relevant methods, however accurately.

 - (void)setPrimitiveRating:(NSNumber*)newRating {
rating = newRating ;
[super setPrimitiveRating:newRating] ;
 }
 
 Result: Compiler warning that my superclass (eventually, NSManagedObject) did 
 not implement this method, a crash at runtime confirming that.

If we stop and think a moment, why would calling super ever work? This is still 
Objective-C, and calling super is only valid when the class' superclass 
implements the method. And I bet NSManagedObject doesn't...

 Conclusion: Primitive accessors are potentially useful but more study is 
 needed to understand how they work, and in particular how to override them 
 without breaking stuff.

Primitive methods are simply the methods for setting an objects values without 
being noticed--i.e. w/o causing KVO or changes notifications to be sent. I am 
sure you understand why. There is absolutely nothing magical about them, 
because they need to be entirely un-magical to escape CD's notice. Therefore it 
is really hard to break anything unless you deliberately do so (or deliberately 
ignore compiler warnings).

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: NSTableCellView Constraints?

2015-01-27 Thread Keary Suska
On Jan 27, 2015, at 7:32 AM, Thomas Wetmore t...@verizon.net wrote:

 I have a multi-column table that I am converting from an ObjC/cell-based 
 implementation to a Swift/view-based implementation. The cells are text, so I 
 am now using a vanilla text-only NSTableCellView in each column.
 
 When the application launches, I can shrink the columns just fine — the text 
 shrinks as it should.
 
 BUT, when I widen the columns the text widens until it reaches the width of 
 the INITIAL LAUNCH TIME WIDTH, and widens no further, no matter how wide I 
 make the columns.
 
 There must be a constraint problem, and I have been playing around with them 
 for awhile, but no joy yet. Googling has not turned up a similar issue. I 
 would have assumed that when I dragged the NSTableCellView into the 
 NSTableColumn using IB, that IB would have established the constraints 
 between the cell view and the column view properly. Apparently not. Is this a 
 known Swift/Cocoa bug or IB bug? Does anyone know the proper workaround? I am 
 running Xcode 6.2 beta 4.

Well, constraints are fully inspectable. What do they show?

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Binding to a view's model object

2015-01-25 Thread Keary Suska
On Jan 25, 2015, at 3:34 AM, Roland King r...@rols.org wrote:

 I have a xib with a top-level view and a bunch of subviews which represents 
 one view of a given model object. The top-level NSView subclass has a 
 readwrite property which is the model object of which it's a view. I thought 
 this was a pretty standard pattern, especially in OSX which only just 
 recently started to really make use of view controllers. 

There is nothing standard about this pattern. It is not, AFAIK, a pattern at 
all, but an anti-pattern. Previous to a view controller the only view 
controller was a window controller, and finer grained control was necessary. 
For this very purpose it is the view controller, and not its view, which tends 
to hold the model object. Hence Xcode is balking at your attempts.

 Many of the subviews just show strings and other values from the model 
 object, and some of them allow editing as well. So what I wanted to do is use 
 bindings to bind modelObject.someStringProperty to the value of one of the 
 text fields, for instance. Doing that would take care of 90% of the easy 
 properties on the model, leaving just a few I'd need to hand-code. However IB 
 doesn't let me make bindings to a property of the top-level view. I can bind 
 to files owner, the shared defaults controller and the application only, or 
 to any other standalone Object I put in the NIB, but none of those help. 

Yes--that's MVC. Views should only bind to controllers, not other views.

 The view in this case is going in a stack view, which wants an NSView. I 
 thought about moving the logic into a view controller which could be the 
 Files Owner, but I would have then to separately retain those view 
 controllers as their views don't retain them and the stackview just wants the 
 view, so that feels a little clunky. The views are meant to be reusable, 
 hence the single readwrite model object property on the view. 

Someone has to own the xib, why not have it serve up the model object? Or own 
the NSViewController(s) that do? These would represent standard patterns and 
don't seem clunky. Note, however, that objects of NSWindowController and 
NSViewController have some built-in binding break-down when they are released, 
and are usually more bindings-friendly.

 Is there a way to do these bindings? Can it be done in IB if so or do I need 
 to call bind:toObject:withKeyPath:options: Is there some other object I could 
 put in the NIB which would intermediate this for me? 

Well, it's hard to say since you haven't listed the items that you don't 
believe you can use bindings for, but in general, yes, more or less.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Binding to a view's model object

2015-01-25 Thread Keary Suska

On Jan 25, 2015, at 6:07 PM, Roland King r...@rols.org wrote:

 
 On 25 Jan 2015, at 23:15, Keary Suska cocoa-...@esoteritech.com wrote:
 
 On Jan 25, 2015, at 3:34 AM, Roland King r...@rols.org wrote:
 
 I have a xib with a top-level view and a bunch of subviews which represents 
 one view of a given model object. The top-level NSView subclass has a 
 readwrite property which is the model object of which it's a view. I 
 thought this was a pretty standard pattern, especially in OSX which only 
 just recently started to really make use of view controllers. 
 
 There is nothing standard about this pattern. It is not, AFAIK, a pattern at 
 all, but an anti-pattern. Previous to a view controller the only view 
 controller was a window controller, and finer grained control was necessary. 
 For this very purpose it is the view controller, and not its view, which 
 tends to hold the model object. Hence Xcode is balking at your attempts.
 
 
 And yet I was certain I'd stolen it from somewhere, and woke up remembering 
 where. NSTableCellView, is a view, has an objectValue property. When you drag 
 an NSTableCellView into IB and add subviews to it, the bindings inspector 
 dropdown for those subviews includes the table cell view, called something 
 like XXX Cell View. So you bind to 'XXX cell view' with path 
 'objectValue.someProperty'. The NSTableCellView is really the VC and 
 objectValue is the model object. 

Of course--in this case, NSTableCellView is really just acting as an 
intermediary for its subviews. In a way, the subviews are really binding 
*through* NSTableCellView , although it is hiding those implementation details. 
That may be what you are after but it didn't seem to be what you were 
describing.

 What I have is a direct rip off of that pattern. I've embedded a stack view 
 in a class and given it a datasource which serves up NSView subclasses for an 
 item at a given index, you can register a nib against an identifier and ask 
 the class to create you a new view or give you a reused one. The method names 
 are even stolen pretty much straight from NSTableView. It's like an 
 NSTableView or a NSOutlineView in usage, just uses a stack view under the 
 hood (because stack view uses autolayout and this makes dynamic row sizing 
 etc super easy when you have rows which use autolayout). IB however knows 
 about NSTableCellViews and adds them into the bindings inspector dropdown for 
 their subviews, it doesn't know about my top-level view class, 
 RKStackCellView, and doesn't. 
 
 I can add them in awakeFromNib pretty easily, do in code what IB does for 
 NSTableCellViews graphically, or I could change my datasource method from 
 returning an NSView*, like NSTableView's does, to returning a view 
 controller, and then keep track of the VCs and their associated views in my 
 stack view using class, as the stack view only wants the NSView but I'd need 
 to keep the VCs referenced somehow to stop them being deallocated. I'll try 
 them both, see which one I like best. 

You can do what you want, you would just have to manage the bindings 
programmatically. It still seems easier to me--and possibly saner--for each 
view to have a VC that holds the model, and to which the subviews are bound.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Cursor above siblings

2015-01-09 Thread Keary Suska
On Jan 9, 2015, at 6:19 AM, ecir hana ecir.h...@gmail.com wrote:

 I have a window with a custom view, which contains two children: a textview
 with scrollbars and a button. I would like to overlay the button over the
 textview so when I click in that area somewhere, the button receives the
 event before the textview. It kind of works, except for one thing: the
 cursor is always of the I-beam variety, even when above the button, see [1]
 and [2].
 
 I think the problem is that the sibling views overlap but don't know how
 to fix it. I tried to move the button beneath the textview in hierarchy but
 that doesn't work (button is not shown) and I tried to `addTrackingArea:`
 but that doesn't work either (maybe I didn't do it the right way but then
 again, I thought NSButton has its own tracking area).
 
 Please, how can I make the cursor change back to the default variety when
 hovering over the button? I can place the button in a custom view and work
 with that view, if that helps..?

It may have changed but my recollection is that interaction with overlapping 
views is undefined. To do what you want you either need to embed the button in 
the text content or use some sort of an overlay window.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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 Keary Suska
On Jan 8, 2015, at 5:43 AM, Charles Jenkins cejw...@gmail.com wrote:

 I need to deal with two issues that are probably already handled in some 
 Cocoa API I just haven't found yet. This email asks about the first of these 
 issues.  
 
 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.
 
 *I encountered this problem a few weeks ago and put off a final solution by 
 using the percent encoding.
 
 Is there already a Cocoa API call that would convert a string to use HTML 
 entities so I could safely put any string into an XML node?

You can apparently route through NSAttributedString (found via StackOverflow):

NSAttributedString *s = [[NSAttributedString alloc] 
initWithString:sourceString];
NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: 
NSHTMLTextDocumentType};
NSData *htmlData = [s dataFromRange:NSMakeRange(0, s.length) 
documentAttributes:documentAttributes error:NULL];
NSString *htmlString = [[NSString alloc] initWithData:htmlData 
encoding:NSUTF8StringEncoding];

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Observing changes in Table

2014-12-17 Thread Keary Suska
On Dec 17, 2014, at 3:02 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:

 A TableView with an ArrayController which has an Array of 
 MutableDictionaries; keys corresponding to TableColumns.
 The table is editable and the dictionary of the edited row gets changed.
 
 All as expected.
 
 But I want to know when any value of any row has been changed by the user, in 
 order to update some data.
 This looks like a very common problem. So probably it has a very simple 
 solution.
 
 But how?

By not using NSMutableDictionary ;-) Generally when one is needs an object with 
a well-defined form, using a specifically defined object (vs NSDictionary) 
tends to be more appropriate. It will be faster, use less memory, and be more 
extensible.

Further, you might run into problems if you need to know exactly which 
object/key was edited in -textDidEndEditing:. I recall having some issue with 
this a while ago, but I don't recall. If you get correct values from -editedRow 
and -editedColumn, and can then map column indexes to keys, you might be fine.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Opening an Embedded Application in Terminal

2014-12-07 Thread Keary Suska
On Dec 7, 2014, at 1:35 PM, SevenBits sevenbitst...@gmail.com wrote:

 
 I don't know if this approach is more likely to work in a sandboxed app.  I 
 doubt it, because it would be an enormous hole in the sandbox.  If you can 
 direct Terminal to run arbitrary commands, what protection does the sandbox 
 provide?
 
 I get your point, but the fact is, I’m not trying to run an arbitrary 
 command, and I don’t even care if Terminal inherits the sandbox from my 
 process. I just need to run this command in a window so that the user can 
 type input in and receive the results back. In other words, I’m looking for 
 Terminal’s user interface, not its ability to run arbitrary commands.
 
 If it matters, the executable is a program that evaluates instructions using 
 REPL (read-eval-print loop).
 
 
 
 I really need this to work as it’s an important aspect of my application. 
 Can anyone advise?
 
 I suspect you have a serious problem, then.  You will probably need to 
 deploy outside of the Mac App Store so that you don't have to sandbox your 
 app.  Alternatively, you can build a terminal emulator UI into your app and 
 run the embedded console program within that, instead of Terminal.  
 Depending on the needs of your console program, that may be a relatively 
 straightforward prospect or a very complex one.
 
 Well, I’m stuck in the middle. On the one hand, implementing a full-brown 
 terminal emulator along the lines of iTerms 2 for my app is overkill and 
 isn’t worth the extra megabytes. But I don’t want to implement a kludgy 
 NSTextField-based interface to feed in input using NSTask and output/input 
 streams either, as it doesn’t look that great.
 
 However, unless someone can come up with a good way to provide a 
 Terminal-like environment for REPL applications, the second approach is the 
 one I’ll probably have to take…

I would first try NSTextView instead--you get a lot of control simply from 
delegate calls, although you will need to subclass. The only tricky part is how 
to handle the parts that would not be editable, and what to do when someone 
tries to edit it. Setting a custom attribute is probably the way to go.

HTH,

Keary Suska
Esoteritech, Inc.



___

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: Predicate Row Template array within array

2014-11-30 Thread Keary Suska
On Nov 30, 2014, at 9:02 AM, Trygve Inda cocoa...@xericdesign.com wrote:

 {
 
 NSString*  name;
 NSDate*date;
 NSArray*   words;
 }
 Objects;
 
 The words array looks like:
 {
 
 NSString*  id;
 NSString*  word;
 }
 Words;
 
 
 As a follow up:
 
 When I use a left expression of:
 
 @words.word
 
 And a modifier of: NSAnyPredicateModifier
 
 My predicate ends up as:
 
 ANY words.word CONTAINS[cd] Test
 
 But I get:
 [__NSCFString 0x61277d00 valueForUndefinedKey:]: this class is not key
 value coding-compliant for the key word.
 
 But it is.

Notice that the object being queried is an NSString, and not the expected 
word object. This either means that your words array contains at least one 
plain NSString, or you are experiencing a memory management issue. Break on 
exception and see what is in that NSString.

HTH,

Keary Suska
Esoteritech, Inc.



___

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: Trouble getting ISO-8859-1 encoded feed to parse and display

2014-11-23 Thread Keary Suska
On Nov 23, 2014, at 11:06 AM, Diederik Meijer | Ten Horses 
diede...@tenhorses.com wrote:

 I am having trouble getting useful data from this url on some, but not all, 
 iOS devices:https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml
 
 The feed has this opening tag: ?xml version=1.0 encoding=ISO-8859-1 ?
 
 When I just pull in the feed’s contents using a NSURLConnection, it will show 
 up on some, but not all, devices.
 
 When I try to log the response data, by creating a string that I init with 
 the downloaded data and NSUTF8StringEncoding, the log will show a null 
 string. So putting the downloaded data into a string using UTF8 doesn’t work.
 
NSString *dataString = [[NSString alloc] initWithData:self.dataContainer 
 encoding:NSUTF8StringEncoding];

The above code is wrong in your case. The second parameter must be the encoding 
that the characters are currently in, not the encoding you want NSString is--at 
least outwardly--encoding-agnostic. It doesn't care what you feed into it, it 
will always spit out UTF8 unless you specify otherwise.

 Still, in that case, some devices will show the parsed feed, some won’t.

Separating the erros in your debugging attempts vs what might actually be 
happening is more useful at the moment.

 I tried converting the data into NSISOLatin1 and then putting it back into 
 NSData using UTF8, as below, but that doesn’t help.

This would be entirely pointless, as the XML parser shouldn't care what 
character encoding is used, as long as it is declared. UTF8 is magical for the 
parser.

 -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *dataString = [[NSString alloc] initWithData:self.dataContainer 
 encoding:NSISOLatin1StringEncoding];

This line is the proper way to convert the data into a string. You can then 
NSLog() with impunity. I would also include the data length, just to make sure 
that a nil result is not due to empty or nil data.

[self setDataContainer:[[dataString 
 dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]];
self.xmlItems = [NSMutableArray array];
NSXMLParser *parser = [[NSXMLParser alloc] 
 initWithData:self.dataContainer];
[parser setDelegate:self];
[parser parse];
 }
 
 
 I validated the feed’s XML and got no errors..

HTH,

Keary Suska
Esoteritech, Inc.



___

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: Deconstructing Text Tables

2014-11-18 Thread Keary Suska
On Nov 18, 2014, at 2:38 AM, Charles Jenkins cejw...@gmail.com wrote:

 It’s very easy to create an NSAttributedString that represents a text table, 
 then show the table in a TextView so the user can edit information in the 
 cells. The documentation on how to create a text table 
 (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TextLayout/Articles/TextTables.html)
  is fairly clear.  
 
 What I don’t see—and maybe it’s there but I just don’t understand it—is how 
 to pull the table apart again. Suppose I want to grab all text from the first 
 cell after the user has edited it. How do I do that?

-rangeOfTextBlock:atIndex: might be your best bet. The hard part is finding 
exactly where you are interested in. If you are only interested in where a 
user has edited, a delegate method may get you there, otherwise, I don't know. 
You may need to keep meta-data about constructed tables.

HTH,

Keary Suska
Esoteritech, Inc.



___

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: NSSplitView divider tracking-area

2014-10-30 Thread Keary Suska

On Oct 30, 2014, at 10:45 AM, edward taffel etaf...@me.com wrote:

 AFAIK the tracking area of the split view is not affected by anything in the 
 way you describe, and looking at the disassembly shows nothing out of the 
 ordinary. The delegate has the ability to add to the area, but that's it.
 
 i’m not sure what you mean—i have verified:
 if the NSPanel is key when mousing over the divider, the cursor changes to a 
 resize cursor, as expected; if not key the cursor is unaffected.

A tracking area can choose when to track, and it appears that NSSplitView has 
chosen to track only when the window is key. You may be able to access the 
tracking area via the -trackingAreas method and swap it out with one of your 
own creation, but that is pretty hacky and probably volatile.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Setting the Selected Segment of a Segmented Control

2014-10-15 Thread Keary Suska
On Oct 15, 2014, at 9:46 AM, Daniel Blakemore dblakem...@pixio.com wrote:

 I can understand that it might behave that way.  It's not in and of itself
 unreasonable, although in my opinion if the selected segment changes
 visually, it's kind of weird not to send the message since the key isn't
 UIControlEventValueChangedButReallyIOnlyCareAboutWhenTheChangeCameFromATouch.
 
 The irksome thing is that it used to work and now doesn't and there's no
 API diff around selectedSegment and the wording in the documentation didn't
 change between iOS 7 and 8.
 
 So I don't know if it's an intentional decision or an oversight.

The docs say,

UIControlEventValueChanged
A touch dragging or otherwise manipulating a control, causing it to emit a 
series of different values.

So, it seems documented to only trigger on a touch event, so it is possible 
that the behavior you had in iOS 7 was unintentional, since there is also no 
mention in release notes of change of behavior.

It is also useful to know that event handling almost exclusively relate to 
device input, not to programmatic changes. I.e., setting the value of a control 
is not an event so no event handling will get involved. You certainly could 
cause an event to programmatically fire…

So the main issue is that you are using an event handling method incorrectly to 
begin with...

 On Tue, Oct 14, 2014 at 9:20 PM, Richard Charles rcharles...@gmail.com
 wrote:
 
 Not sure about iOS but on OS X programmatically calling
 
[NSSegmentedControl setSelectedSegment:]
 
 does not trigger the target / action message.
 
 You need to programmatically respond after setting the selected segment.
 
 Richard Charles
 
 On Oct 14, 2014, at 6:55 PM, Daniel Blakemore dblakem...@pixio.com
 wrote:
 
 I have a simple problem.  I am programmatically setting the selected
 segment of a segmented control.  Then the segmented control is changing
 which segment appears selected on screen.
 
 You might be saying to yourself, this seems correct.  You would also be
 correct.
 
 What is incorrect is that while the control *appears* to have changed, my
 code knows nothing of this.
 
 I have an action added for the control event UIControlEventValueChanged
 which is called as expected when you tap the control.
 
 HOWEVER, when changing the control programmatically, no such event is
 generated.  This leaves my app in an inconsistent state.
 
 For reference, see this example project
 https://github.com/danblakemore/SegmentedNope.
 
 This worked in iOS 7.  It now does not.  What has changed?
 
 --
 Daniel Blakemore
 Pixio Software
 ___
 
 
 ___
 
 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/cocoa-dev%40esoteritech.com
 
 This email sent to cocoa-...@esoteritech.com

Keary Suska
Esoteritech, Inc.



___

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: NSPopover tear-off problem

2014-10-13 Thread Keary Suska
On Oct 12, 2014, at 10:02 PM, Graham Cox graham@bigpond.com wrote:

 On 13 Oct 2014, at 2:43 pm, Graham Cox graham@bigpond.com wrote:
 
 But if I turn the popover into a window by allowing it to be dragged, the 
 window's content is screwed up - instead of sizing the overall view to fit 
 the window, a subview (an NSTableView) is sized to fill the window, and some 
 other views (a search field and a button) end up on top of the table. The 
 button is in the right place, but the search field is too wide and extends 
 beyond the window edge. Perhaps there is a problem with having a table view 
 inside a popover? It seems to work fine, so I think that's unlikely. Perhaps 
 the problem is with struts/springs being translated into constraints?
 
 A further clue I've just doscovered: if I set the popover.animates = NO, the 
 window is shown properly with its content in the right places. This suggests 
 that the issue is with NSPopover's animation to the window. It seems to be 
 trying (and failing) to be too clever, animating each subview's frame to its 
 equivalent in the window.
 
 However, since it has no possible information about which view in the two 
 places are equivalent to each other, it must be using some sort of brain-dead 
 method to figure out the associations. This is really stupid - either 
 implement a method so that our code can give it the information or do not 
 attempt such a thing. It seems it's deciding that my table must be the 
 overall view and so sizes it to fit the window. Wrong! It wouldn't be quite 
 so bad if I had the opportunity to fix it up but I don't.


I came across this problem, although my theory was that the window was being 
sized from small to larger, which of course makes springs and struts whacko 
when views ares forced to overlap. Even auto layout doesn't solve it quite--I 
had to make sure that every subview had a fixed position. Even then, the 
content view would have a bad origin (0,-8) and I had to override setFrame: to 
correct it. This might have been a 10.7 bug, as I haven't tested it since.

There may be a way with auto layout-based animations, but I haven't the 
wherewithal to pursue it.

HTH,

Keary Suska
Esoteritech, Inc.



___

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: Questions on using a NSTextView as a source viewer.

2014-10-11 Thread Keary Suska
On Oct 11, 2014, at 3:53 AM, Daryle Walker dary...@mac.com wrote:

 On Oct 10, 2014, at 1:58 AM, Ken Thomases k...@codeweavers.com wrote:
 
 On Oct 10, 2014, at 12:02 AM, Daryle Walker dary...@mac.com wrote:
 
 On Oct 7, 2014, at 8:03 PM, Ken Thomases k...@codeweavers.com wrote:
 
 On Oct 7, 2014, at 5:29 PM, Daryle Walker dary...@mac.com wrote:
 
 1. Although the text in the window expands vertically as needed, it never 
 does horizontally. Wrapping always happens when lines are too long, but 
 it adjusts as the width of the window is changed. How do I get “infinite” 
 space horizontally? I tried various tweaks in Interface Builder and 
 looked at various Apple guides, but I can’t turn off the horizontal 
 wrapping.
 
 On the Size inspector of IB, enable Resizable Horizontally.  Then, in 
 code, do this (assuming self.textView is the outlet property):
 
 self.textView.textContainer.widthTracksTextView = NO;
 
 I couldn't find anyplace in IB that exposes the text container attributes.
 
 I added “textContainer.widthTracksTextView” to the run-time attributes 
 section in Interface Builder as a Boolean, and it changes the behavior in 
 the other direction; the text wraps at the window’s original width, even if 
 I make the window wider. Changing it to YES (i.e. turning on the checkbox) 
 brings back the previous behavior. (I first changed the horizontal point 
 limit to 10K, just like the vertical limit.)
 
 Did you also set Resizable Horizontally (the first step, above)?  And, yes, 
 good catch: I forget to mention changing the max. width.
 
 Yes.
 
 I tested this and it worked for me.  In summary, all three steps:
 
 * Set the text view's max. width
 * Set the text view to be horizontally resizable
 * Set textView.textContainer.widthTracksTextView = NO
 
 I had that before my last post; didn’t fix it, made it worse (text width is 
 the initial width of the window, even if I Zoom it out, or manually make it 
 wider, or narrower(!)).


I think Ken mis-stated what he meant--the max width isn't terribly relevant. 
You need to set the actual container size (width minimally) to an unlikely 
large number. Apple's TextViewSizing example project demonstrates this. They 
use the value 1.0e7, which comments say is the largest possible value before 
experiencing text drawing issues. You will have to set this value in code, as 
it can't be set via IB.

 On Oct 7, 2014, at 5:33 PM, Daryle Walker dary...@mac.com wrote:
 
 3. The text in the view-source window is editable, although I turned that 
 off. (It’s still selectable.) I can cut/copy/paste. Isn’t turning off 
 editing supposed to stop this?
 
 Are you using bindings?  Do any of them have Conditionally Sets Editable 
 enabled in the binding options?
 
 Yes, one for the text view's contents, and another on the window's title 
 (using the format substitution version). There is a binding for the text 
 view being editable, but I’m not using it. (The text contents property in 
 my window controller class is read-write.)
 
 My point was to check the options on those bindings for the Conditionally 
 Sets Editable option.  If any of them have that option enabled, that would 
 explain why your text is editable when you set the text view to 
 non-editable.  The binding option is overriding the attribute you set.  Turn 
 it off.
 
 I thought you meant the “Editable” attribute under “Availability.” I haven’t 
 activated that Binding at all. But now I see you meant the C.S.E. option 
 under the Binding I did make. That option is checked.
 
 Turning it off blocks Cut and Paste, but still allows Copy, Select All, and 
 Find.

You will need to also turn off selectable (setSelectable: in code) which 
should disable the rest, and possibly change find value to none 
(setUsesFindBar: and/or setUsesFindPanel:).

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Questions on using a NSTextView as a source viewer.

2014-10-11 Thread Keary Suska
On Oct 11, 2014, at 1:31 PM, Daryle Walker dary...@mac.com wrote:

 There was a minor detour where I just had “textContainer.containerSize” set. 
 You need BOTH “containerSize” and “widthTracksTextView” set (to {10M, 10M} 
 and NO, respectively). Both of these can be set in the user-defined run-time 
 attributes section of IB. I heard about this a few months ago as a power-user 
 hint. I first tried it to set the text-view’s font to the system fixed-width 
 font, but I couldn’t do it. NSFont is not a type supported by the runtime 
 attribute section, but NSSize and BOOL are.

I stand corrected. I think this was new as of Xcode 5, since I haven't used 
that feature since Xcode 4, but I am glad the added it.

 Oh, I want read-only actions supported. Those don’t break the illusion that 
 the source-view and browser windows are connected.

Sorry, I misunderstood. I thought you didn't want those either.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Table of TextViews

2014-10-09 Thread Keary Suska
On Oct 9, 2014, at 7:40 AM, Charles Jenkins cejw...@gmail.com wrote:

 Thank you, Ken. Originally I started out by implementing the table view using 
 a data source and delegate. With some help from list members, I got that 
 working pretty well except for row height. I only started my latest test app 
 using NSArrayController and bindings because I mistakenly thought the Row 
 Height binding would be useful.
 
 Here’s the problem I have: I can set up my text container and text view to 
 pin their widths to the enclosing scroll view, no problem. And I can set the 
 text container to size itself vertically to fit the text, and I can set my 
 text view to size itself vertically to fit the text container. All that has 
 worked for me in a demo app. The only piece missing is to get the text view 
 to call the table view’s noteHeightOfRowsWithIndexesChanged:
 
 I create the text views programmatically instead of using IB, because 
 apparently the only way to get ‘em in IB is enclosed in individual scroll 
 views I don’t need. So how can I get my individual, programmatically created 
 text views to react by notifying the table view when they update their size?  

You generally wouldn't, as they are both views. You could have a custom 
subclass of NSTableView or you would have a controller--preferably the table 
view delegate as it knows the most about the table view--send 
noteHeightOfRowsWithIndexesChanged: when it is told (possibly by NSTextView 
delegate method or notification) that the text view size needs to change.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: A Stack of Editors

2014-10-05 Thread Keary Suska
On Oct 4, 2014, at 8:49 PM, Charles Jenkins cejw...@gmail.com wrote:

 Keary, I see you’re right: NSTableViewDelegate’s tableView:heightOfRow: will 
 be key if my stack of editors appears in a table view. I’ve been struggling 
 all day to get a test program to call my delegate’s functions. I must say, 
 the table view is a very disheartening object to work with.
 
 John, I am sort of doing a master-detail type of thing. I’m trying to 
 implement my own version of Jer’s Novel Writer. On the left side of the 
 screen, there’ll be an Outline View of a novel’s structure, with chapters and 
 scenes. On the right, a stack of text views. If a single scene is selected in 
 the outline, then the stack will contain one editor. But if a chapter is 
 selected, then there’ll be one editor for each scene within it. (Each scene 
 is stored in a separate RTF file in the document’s package file.) I think my 
 stack can be as large as needed without regard to the window’s height: the 
 whole thing will be contained within a scroll view.
 
 I tried working with the NSStackView yesterday, and it would only overlay my 
 subviews on top of one another, rather then presenting them in a vertical 
 column as expected. I created 16 variously sized NSBox objects and used a 
 loop to add each one to the top gravity of the stack view. Because the boxes 
 were different sizes, I could see that they were laid uselessly on top of one 
 another like cards in a deck.
 
 Today I’m using the same array of NSBoxes, but trying to put them into a 
 single-column table. My table-manager class acts as both a data source and 
 delegate, and because of breakpoints I know that my data source methods are 
 called as expected, as well as some delegate ones, but the methods important 
 to my needs are never called. The table view is set up as view-based in IB 
 and does not have a fixed row size. However, tableView:viewForColumn:row and 
 tableView:heightOfRow: are never called.
 
 I’ve struggled with these all day and still can’t figure out why the methods 
 that matter don’t get called. I copied the prototypes directly from the 
 NSTableView documentation and only renamed some variables. I’ve checked 
 several times that the table is configured to be view-based and has no fixed 
 row size. Assuming I’ve got the prototypes right, can anyone suggest reasons 
 why the table would call some delegate methods, but not the important ones 
 shown below?

Sometimes the most obvious issue is the culprit--is the delegate outlet set? If 
so, are any other delegate methods being called? Note that you might not get a 
call for certain delegate methods if there is no data to show--i.e. if the 
table view doesn't otherwise believe it has data to show, either via bindings 
or data source methods.

I suspect, however, that you will have better results from Jonathan's 
suggestion of a vanilla NSScrollView, especially if you are dealing with fixed 
numbers of rows. You can have pre-made NSViews that you can swap in and out 
as its document view. The other types of views (NSTableView, NSStackView, 
NSCollectionView) are really for dealing with arbitrary numbers of elements, 
and are probably heavier than you need.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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

Validate NSDocument on Quit

2014-10-05 Thread Keary Suska
I am trying to prevent a quit in a document-based app when data in a document 
is invalid. AFAICT when auto save is turned on none of the normal document 
closing methods are called, and when the app delegate is called, 
NSDocumentController shows no existing documents. It might also have to do with 
the Ask to keep changes preference. Has anyone figured out how to trap 
closing to prevent saving possibly invalid data?

TIA,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: A Stack of Editors

2014-10-04 Thread Keary Suska
On Oct 3, 2014, at 8:27 PM, Charles Jenkins cejw...@gmail.com wrote:

 What I’m trying to make is a scroll view containing a vertical stack of 
 editors for RTF subdocuments. Each of the text views should size itself to 
 fit the width of the scroll view, but grow vertically as much as necessary to 
 display its full content.
 
 The more I think about it, the more I think what I need is a single-column 
 table view within which each cell holds a text editor. But each row, text 
 view, and text container should resize to fit the text held within. How can I 
 achieve that?

View-based NSTableView? There is a way that you can tickle the table view 
into resizing the row although you will have to figure out how and when to 
determine the appropriate size. Another problem to watch put for is whether 
resizing ends the editing session.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: return string that is the difference between two other strings

2014-09-20 Thread Keary Suska
On Sep 20, 2014, at 11:13 AM, 2551 2551p...@gmail.com wrote:

 For example:
 
   NSString *mary = @mary had a little lamb, a little lamb she had;
NSString *scary = @mary had a little lamb, a little naughty fella of a 
 lamb she had for sure;
NSString *isDifferent = [self getDifference:mary and: scary];
NSLog(@%@, isDifferent);
 
 The method I posted below produces the difference that I want (naughty fella 
 of a for sure). But I want to know if there's a more orthodox and robust 
 solution. 
 

I would use an NSOrderedSet and NSCharacterSet for robustness, e.g.:

NSMutableCharacterSet *separatorSet = [NSMutableCharacterSet 
punctuationCharacterSet];
[separatorSet formUnionWithCharacterSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]];
NSMutableOrderedSet *maryWords = [NSMutableOrderedSet orderedSetWithArray:[mary 
componentsSeparatedByCharactersInSet:separatorSet]];
NSMutableOrderedSet *scaryWords = [NSMutableOrderedSet 
orderedSetWithArray:[scary componentsSeparatedByCharactersInSet:separatorSet]];
BOOL maryLonger = [maryWords count]  [scaryWords count];
[(maryLonger ? maryWords : scaryWords) minusOrderedSet:(maryLonger ? scaryWords 
: maryWords)];
NSLog(@%@, (maryLonger ? maryWords : scaryWords));

Though this wouldn't account for order or duplicates, but neither would your 
implementation.

 
 -(NSString *)getDifference: (NSString *)aString and:(NSString 
 *)anotherString {
  int i = aString.length;
  int j = anotherString.length;
  NSString *result, *longest, *shortest;
 
  if (i == j) {
  result = @;
  return result;
  }
 
  if (i  j) {
  longest = aString;
  shortest = anotherString;
  } else {
  longest = anotherString;
  shortest = aString;
  }
 
  NSArray *fa = [longest componentsSeparatedByString: @  ];
  NSArray *sa = [shortest componentsSeparatedByString: @ ];
  NSMutableArray *remainder = [NSMutableArray arrayWithArray:fa];
  [remainder removeObjectsInArray:sa];
  result = [remainder componentsJoinedByString:@ ];
  return result;
 
 }


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Still need help with Services. Is there sample code?

2014-09-18 Thread Keary Suska
On Sep 18, 2014, at 3:22 PM, Daryle Walker dary...@mac.com wrote:

 I removed the old style type (“NSStringPboardType”) and it still worked. When 
 I changed the “public.plain-text” to “public.url” and tested with the entry 
 field on Firefox, Safari’s “Open URL” service showed up, but my version 
 didn’t! Same thing happened using “NSURLPboardType” as the send type. 
 Renaming the public name of my service, so it wouldn’t match Safari’s, didn’t 
 work. Changing the send-type to “public.url-name” didn’t work.
 
 Now we narrowed what’s wrong. I still don’t know how to fix it. 

At this point, you are probably just looking at a UTI issue. Standard UTI's are 
documneted in the UTCoreTypes.h header. I don't know if they are documented 
elsewhere. Simply open terminal and execute locate UTCoreTypes.h to find the 
various headers.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Still need help with Services. Is there sample code?

2014-09-16 Thread Keary Suska
On Sep 16, 2014, at 6:22 AM, Daryle Walker dary...@mac.com wrote:

 Still can’t get my Service to trigger.
 
 daryle$ /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices 
 io.github.me.MyApp
 2014-09-16 08:00:58.493 TextEdit[546:507] NSDebugServices=io.github.me.MyApp
 Open URL (io.github.me.MyApp) is explicitly enabled in the services menu and 
 enabled in the context menu, in preferences.
 Open URL (io.github.me.MyApp) is explicitly enabled in the services menu and 
 enabled in the context menu, in preferences.
 Open URL (io.github.me.MyApp) is disqualified because its send and/or return 
 types cannot be handled by the requestor NSTextView: 0x7fc35345d950
Frame = {{0.00, 0.00}, {550.00, 420.00}}, Bounds = {{0.00, 0.00}, 
 {550.00, 420.00}}
Horizontally resizable: NO, Vertically resizable: YES
MinSize = {550.00, 420.00}, MaxSize = 
 {179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00,
  
 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00}
 .
 
 The first two lines after the command always appear. The rest of the lines 
 happen every time I open the Services menu, no matter the context. (The error 
 messages are happening when the system checks if my Service qualifies.) 
 Web-searching got only one hit on is disqualified because its send and/or 
 return types cannot be handled by the requestor”; the page was from Stack 
 Overflow. It mentioned a post on this list from 5 years ago, suggesting 
 adding an “NSRequiredContext” entry. It didn’t help me; still getting the 
 same error. (The “MaxSize” numbers are one huge line; it wraps here.)
 
 I’m stumped. I’ve been looking for Apple sample code, but since it likes 
 tacking on “service” to 80% of its stuff, I can’t find anything.
 
 Here’s the Services portion of my Info.plist, in case I’m still missing 
 something simple:
 
  keyNSServices/key
  array
  dict
  keyNSMenuItem/key
  dict
  keydefault/key
  stringOpen URL/string
  /dict
  keyNSMessage/key
  stringopenURL/string
  keyNSPortName/key
  stringPrairie/string
  keyNSSendFileTypes/key
  array
  stringpublic.text/string
  /array
  keyNSRequiredContext/key
  dict
  keyNSServiceCategory/key
  stringpublic.text/string
  /dict
  /dict
  /array
 
 I could post the source code again, but the lack of any logging from that 
 method means the process is failing before the method would be called. I did 
 at one time add an -init and -dealloc with logging just to make sure the 
 object was created and retained. I got just the init message, which means 
 that the service provider was being retained and not instant-deallocated.
 
 Oh, the Stack Overflow page was 
 http://stackoverflow.com/questions/1370616/nsservices-not-working and the 
 referenced post was 
 http://lists.apple.com/archives/Cocoa-dev/2009/Sep/msg00201.html.

I am not sure how you are googling, but I found a solution as the first hit. I 
always do full phrase searches on error messges for best results. See this: 
http://lists.apple.com/archives/cocoa-dev/2012/Jun/msg00382.html as it has the 
exact same problem, with solution. Use that info.plist as a sample and see if 
you have better success.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Binding Exception

2014-09-15 Thread Keary Suska

On Sep 15, 2014, at 2:42 PM, Richard Charles rcharles...@gmail.com wrote:

 I have a binding that throws an Objective-C exception but the console 
 displays no output and the application does not crash but rather the 
 application runs fine. Enabling NSBindingDebugLogLevel 1 does not help, the 
 console still displays nothing. I am using Xcode 5.1.1 with the All 
 Exceptions breakpoint enabled.
 
 [self bind:@allowSelection
   toObject:_customView.window.windowController

 withKeyPath:@“widgetControllerManager.activeWidgetController.allowSelection
options:nil];
 
 The stack trace looks like this.
 
 #0 0x7fff909f0e4a in objc_exception_throw ()
 #1 0x7fff8a3f710c in +[NSException raise:format:] ()
 #2 0x7fff94b152a7 in -[NSObject(NSKeyValueCoding) setNilValueForKey:] ()
 #3 0x7fff94a4472e in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
 #4 0x7fff88549f0d in -[NSObjectParameterBinder 
 _updateObject:observedController:observedKeyPath:context:] ()
 #5 0x7fff88540f08 in -[NSObject(NSKeyValueBindingCreation) 
 bind:toObject:withKeyPath:options:] ()
 
 This application contains lots of programatic bindings similar to this one. 
 However this is the only one which throws an exception.
 
 Should I be concerned about this?

Yes, The exception will leave your app in an invalid state.

 Is there anyway to debug this?

The breakpoint catches before the exception would be logged to console. Simply 
keep clicking the continue button in the debugger until it outputs the 
exception. Then read the Key-Value Coding guide on when setNilValueForKey: is 
called and how you can handle it. 

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Responder Chain Confusion

2014-09-07 Thread Keary Suska
On Sep 7, 2014, at 10:24 AM, dangerwillrobinsondan...@gmail.com wrote:

 I just spent a bit of time poking around the responder chain and nil targeted 
 actions. 
 I built a view controller and a view hierarchy with controls that should be 
 configurable. 
 When instantiating the view controller the interface allows configuring the 
 action SEL of the controls. Reuse is the goal of course. 
 I know 10.10 changes things greatly for view controllers. But on 10.9 that's 
 not there. 
 
 Anyway, I need to insert the view controller into the responder chain between 
 its top level view and that view's superview. 
 That wasn't too bad. Implement the missing reference to the vc in a view 
 subclass and give the vc a callback when the view is in place. 
 
 But what I found while tinkering is that for non-document based apps from a 
 vanilla project template there was no next responder for the window or the 
 NSApplication instance. 
 I had a method in the app delegate that I was trying to reach via nil 
 targeted action. It couldn't get there. 
 So I set the window nextResponder to the app and the app to the app delegate. 
 I also made the app delegate an NSResponder subclass. 
 
 It feels like overkill. 
 Am I missing something simple?
 Is there something better to do here?

My inclination is that you broke something in your attempts to insert your VC 
into the responder chain. The app delegate is always the last responder. Any 
vanilla template will show that the app delegate will respond to unhandled 
action message. In a vanilla project of any kind (that has a window), implement 
the action message in your app delegate, wire up a nil-targeted action in a 
menu, say, then see whether it is handled. If it is not, I would file a bug, 
because I cannot reproduce this behavior.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: NSTextAlignment Enum?

2014-09-01 Thread Keary Suska
On Sep 1, 2014, at 4:51 AM, Dave d...@looktowindward.com wrote:

 I have a method that takes a String and depending on it’s value needs to 
 return an NSTextAlignment type. However, if the string is invalid, then I 
 want to indicate that an error so I pass back -1. This is fine expect I get 
 warnings on this code:
 
 if (myTextAllignment != -1)
   theFieldOutlet.textAlignment = myTextAllignment;
 
 Warning:
 
 Comparison of constant -1 with expression of type 'NSTextAlignment' (aka 
 'enum NSTextAlignment') is always true
 
 What is the best way to fix this?

NSTextAlignment in declared in NSText.h, as you will see by looking at the 
constants section of the doc. It is an NSUInteger, so obviously trying to push 
-1 is an issue. If you don't want to return a proper NSTextAlignment value in 
some instances, than the property should not be declared as an NSTextAlignment 
type, because clearly it is not. You can change the type to NSInteger, but that 
may not be future-proof. The truly best approach, IMHO, is to catch the error 
at the point it occurs, rather than relying on a fragile, interpreted value. 
E.g. having a method:
- (BOOL)parseTextAlignment:(NSTextAlignment *)alignPtr
is a smarter way to go (IMHO).

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: NSTextAlignment Enum?

2014-09-01 Thread Keary Suska

On Sep 1, 2014, at 9:28 AM, Keary Suska cocoa-...@esoteritech.com wrote:

 On Sep 1, 2014, at 4:51 AM, Dave d...@looktowindward.com wrote:
 
 I have a method that takes a String and depending on it’s value needs to 
 return an NSTextAlignment type. However, if the string is invalid, then I 
 want to indicate that an error so I pass back -1. This is fine expect I get 
 warnings on this code:
 
 if (myTextAllignment != -1)
  theFieldOutlet.textAlignment = myTextAllignment;
 
 Warning:
 
 Comparison of constant -1 with expression of type 'NSTextAlignment' (aka 
 'enum NSTextAlignment') is always true
 
 What is the best way to fix this?
 
 NSTextAlignment in declared in NSText.h, as you will see by looking at the 
 constants section of the doc. It is an NSUInteger, so obviously trying to 
 push -1 is an issue. If you don't want to return a proper NSTextAlignment 
 value in some instances, than the property should not be declared as an 
 NSTextAlignment type, because clearly it is not. You can change the type to 
 NSInteger, but that may not be future-proof. The truly best approach, IMHO, 
 is to catch the error at the point it occurs, rather than relying on a 
 fragile, interpreted value. E.g. having a method:
   - (BOOL)parseTextAlignment:(NSTextAlignment *)alignPtr
 is a smarter way to go (IMHO).

One future-proof approach that occurred to me is to declare your own enum:

typedef NS_ENUM(NSInteger, MYTextAlignment) {
MYInvalidTextAlignment  = -1,
MYLeftTextAlignment = NSLeftTextAlignment,
MYRightTextAlignment= NSRightTextAlignment,
MYCenterTextAlignment   = NSCenterTextAlignment,
MYJustifiedTextAlignment= NSJustifiedTextAlignment,
MYNaturalTextAlignment  = NSNaturalTextAlignment
};

Although  still think it is better to trap errors early and on-time, whenever 
possible.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Printing onto custom paper (filling in forms)

2014-08-28 Thread Keary Suska
On Aug 28, 2014, at 7:20 AM, Ben ben_cocoa_dev_l...@yahoo.co.uk wrote:

 I'm trying to make a tool for myself to fill in some repetitive forms. 
 They've got a custom paper size with a series of boxes to be filled in.
 
 Given that I know the dimensions of the paper and the locations and 
 dimensions of the boxes to fill in, I should be able to draw a view that 
 prints onto these sheets. However, I'm getting lost in the printing system 
 trying to figure out what steps I need to take to get this working.
 
 I don't understand how to go from the physical paper size (say 80mm wide, 
 150mm tall) to the paper size Cocoa wants in points. Is there a method that 
 gives a scaling factor from points to any physical unit?
 
 I'll also need to precisely position drawn strings in the view to print, so 
 will presumably need to translate points to physical dimensions when drawing 
 too.
 
 Can anyone point me to something that might explain how to proceed here?

As the docs say, sizes are measured in the user coordinate space: 
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html#//apple_ref/doc/uid/TP40003290-CH204-SW5

This guide is important to read as well.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: Printing onto custom paper (filling in forms)

2014-08-28 Thread Keary Suska
On Aug 28, 2014, at 8:56 AM, Ben ben_cocoa_dev_l...@yahoo.co.uk wrote:

 
 On 28 Aug 2014, at 15:01, Keary Suska cocoa-...@esoteritech.com wrote:
 
 On Aug 28, 2014, at 7:20 AM, Ben ben_cocoa_dev_l...@yahoo.co.uk wrote:
 
 I'm trying to make a tool for myself to fill in some repetitive forms. 
 They've got a custom paper size with a series of boxes to be filled in.
 
 Given that I know the dimensions of the paper and the locations and 
 dimensions of the boxes to fill in, I should be able to draw a view that 
 prints onto these sheets. However, I'm getting lost in the printing system 
 trying to figure out what steps I need to take to get this working.
 
 I don't understand how to go from the physical paper size (say 80mm wide, 
 150mm tall) to the paper size Cocoa wants in points. Is there a method that 
 gives a scaling factor from points to any physical unit?
 
 I'll also need to precisely position drawn strings in the view to print, so 
 will presumably need to translate points to physical dimensions when 
 drawing too.
 
 Can anyone point me to something that might explain how to proceed here?
 
 As the docs say, sizes are measured in the user coordinate space: 
 https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html#//apple_ref/doc/uid/TP40003290-CH204-SW5
 
 This guide is important to read as well.
 
 
 I've read that before, but not thought to apply it to print devices.

Well, first you need to draw what you need to print, and then print it, so all 
of the Cocoa drawing API's apply.

 If I understand correctly, I should basically just work everything out at 
 72dpi (the assumed user space scale) and let the system sort out the scaling 
 for the printer?

Yes. I find this works well for basic drawing. You do lose some precision--for 
instance, you can't really do any fractional pixel drawing--but text will come 
out perfectly.

 So for my case, assuming 72dpi ≈ 2.8 dots/mm:
 The paper being 80mm wide should be set to 224 points wide
 To inset a label by 10mm from an edge, I should inset by 28 points?
 
 Am I understanding this right?

Yes.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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: How to synchronize my MacOS-X application with Core-Data automatic Undo management?

2014-08-26 Thread Keary Suska
On Aug 26, 2014, at 7:34 AM, Motti Shneor su...@bezeqint.net wrote:

 Let's say we have the standard Organization-Department-Employee 
 application with two level ordered relations, Each Document representing a 
 distinct persistent store with a single Organization and its departments and 
 employes. The window shows (source/detail) Departments by ordered relation 
 and Employees table by ordered relation to department.
 
 In my document NSWindowController, there are two references, to the 
 
 @property (atomic, readwrite, weak) NSManagedObject *currentDepartment; // 
 and 
 @property (atomic, readwrite, weak) NSManagedObject *currentEmployee;
 
 (I know this example calls for using the table or array controller selection 
 instead of those references, but my case has no selection per se. I need 
 those current references, to which I apply actions and changes as the 
 program runs.)
 
 Consider the following menu item IBActions:  Next Department and Next 
 Employee. 
 
 Next Department will look if the currentDepartment is the last on the 
 relation. if not, it will set the currentDepartment reference to the next one 
 (may change from nil to first Department). Otherwise (currentDepartment is 
 last) it will create a new Department entity, and set the reference to it. 
 Last, it will invoke the Next Employee (below) action.
 
 Next Employee is similar. it looks if the currentEmployee is the last on 
 the relation. if not, it will change the currentEmployee reference to the 
 next one (may change from nil to first Employee). Otherwise (currentEmployee 
 is last) it will create a new Employee entity, and set the reference to it.
 
 After several iterative Next Department and Next Employee actions from 
 the user, we have several entities, and two references to some department and 
 employee --- not necessarily the last ones. I'd like Undo from the user, to 
 do EXACTLY what it does today, reverting the creation of new departments and 
 employees, but also to revert the changes of those references.
 
 From what I've read so far, I guess I need to register my own Undo actions 
 in the Next Department and Next Employee implementations. But ---
 
 * Onto what NSUndoManager?

Generally the one belonging to your NSManagedObjectContext instance.

 * When should I do this? before, or after my calls to CoreData?

You would tend to register undo action in the order they need to be *undone*, 
but logically if you need to make changes in response to changes made to a 
context, you would register your actions after the changes are made.

 * How can I be sure that my own undo actions are correctly grouped with those 
 CoreData registers?

AFAIK you should be able to trust that undo actions you register in the same 
run loop cycle will be grouped into a single undo.

 * Will this work in cases where Next Employee or Next Department move 
 within existing entities, and do not create any entities? 

Sure, just remember that you are registering an undo that will be 
user-undoable. This may create a peculiar UI, as users may not expect an undo 
action to effect navigation. It seems like you would only be concerned about 
handling undo during creation, so that may be the only case you will want to do 
so.

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

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

  1   2   3   4   5   6   7   8   >