Re: Avoiding leaks with "initWithCGImage"

2023-08-23 Thread Sandor Szatmari via Cocoa-dev
You mention ARC… aren’t you not supposed to explicitly release objects under 
ARC?  Am I misunderstanding?

Sandor

> On Aug 23, 2023, at 18:48, JPH via Cocoa-dev  
> wrote:
> 
> Hello friends,
> 
> The enclosed procedure is producing a NSImage from  another NSImage, by 
> cropping in a NSRect.
> The resulting sub-Image feeds  an imageView  in the APP Interface and the may 
> change frequently,  then being hopefully disposed by ARC
> The last line of the procedure :
> NSImage *subImage = [[NSImage alloc] initWithCGImage:subImageRef 
> size:NSZeroSize];
> Generates a leak problem.
> 
> it is quite unclear if i should release or not  the  subImageRef.
> 
> If I release,  the app crashes soon after.
> If I don’t release, Instrument/Leaks reports a leak  of subImageRef  after 
> each call.
> 
> Obviously, ARC never releasessubImageRefwhich, as far as I 
> understand, is owned by the  subImage after the call.
> 
> Digging the web , apple doc, and various AI, did not provide a solution to 
> this dilemme.
> 
> I would greatly appreciate some help on this
> 
> Happy summer.. 
> JP
> 
> C
> //=
> + (NSImage *)getSubImageFromImage:(NSImage *)image atRect:(NSRect)rect
> //=
> {
>  // Convert the NSImage to a CGImageRef
>  CGImageRef imageRef= nil, subImageRef= nil;
>  imageRef = [image CGImageForProposedRect:NULL context:nil hints:nil];
>  if (imageRef == nil ) {  return nil; } // Failed to create CGImageRef
>  // Get the subimage from the CGImageRef
>  subImageRef = CGImageCreateWithImageInRect(imageRef, rect);
>  CFRelease(imageRef);
>  if(subImageRef == nil ) {  return nil;  }  // Failed to create subImageRef
>  // Convert the subimage CGImageRef to an NSImage
>  NSImage *subImage = [[NSImage alloc] initWithCGImage:subImageRef 
> size:NSZeroSize];
> //   CFRelease(subImageRef); // it is quite unclear if i should release the  
> subImageRef
> //If I release, the app crashes soon after.
> // If i dont release Instrument/Leaks report a leak at next call.
> // The subImage goes to a NSbutton in the interface, and will also soon be 
> replaced by another one, producing a leak of subImageRef
> 
>  return subImage;
> }// getSubImageFromImage
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: dictionaryWithObjects:keys: looses elements

2023-01-04 Thread Sandor Szatmari via Cocoa-dev
Did you dump the arrays to the console to verify uniqueness of your keys?

Can you show that output here?

Sandor

> On Jan 3, 2023, at 17:53, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have this line in my code:
> 
>NSDictionary * temp = [NSDictionary dictionaryWithObjects: imagefiles_ 
> forKeys: datesAndTimes_ ];
> 
> The funny thing is: 
> the input arrays (imagefiles_ and datesAndTimes_) both have 17 elements;
> however, the dictionary temp has only 7 elements afterwards!
> 
> In the debugger, both input arrays appear to be OK, nothing peculiar about 
> them.
> 
> The array for the keys is constructed essentially the following way:
> 
>iso_date = [isoDateFormatter_ dateFromString: (__bridge NSString * 
> _Nonnull)(dateref) ];
>[datesAndTimes_ addObject: iso_date ];
> 
> (I also tried 
> 
>[datesAndTimes_ addObject: [iso_date copy] ];
> 
> to no avail.)
> 
> The values array is constructed like this:
> 
>imagefiles_ = [NSMutableArray arrayWithArray: [filelist 
> componentsSeparatedByString: @"\n"] ];
> 
> 
> I'd be very grateful if anybody could shed some light on this.
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
I was thinking that’d break sandbox encapsulation.  But I guess what really 
matters is what you get when you do the reverse and expand the tilde?

> 
> On Dec 11, 2022, at 17:58, Ben Kennedy via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On 11 Dec 2022, at 12:51 pm, Mike Abdullah via Cocoa-dev 
>>  wrote:
>> 
>> Have you tried -URLByResolvingSymlinksInPath? As far as I’m aware, the 
>> Pictures entry inside your container is a symlink to the real thing, so 
>> assuming you have appropriate entitlements, should be possible to resolve it.
> 
> 
> Indeed, it seems to work in a Swift REPL. Issuing...
> 
> (URL(fileURLWithPath: 
> "/Users/ben/Library/Containers/com.apple.ScreenSaver.Engine/Data/Pictures").resolvingSymlinksInPath().path
>  as NSString).abbreviatingWithTildeInPath
> 
> ...yeilds "~/Pictures".
> 
> -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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
Looking back, I guess you’d bump up against the sandbox with this… 

> 
> On Dec 11, 2022, at 16:21, Sandor Szatmari  
> wrote:
> 
> -stringByAbbreviatingWithTildeInPath
> 
> First page in google results
> 
>> On Dec 11, 2022, at 15:06, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> 
>> I have an NSURL * pictures_path;
>> 
>> By default, this is set to 
>> 
>> pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
>> NSPicturesDirectory
>>inDomain: NSUserDomainMask
>>   appropriateForURL: nil create: NO error: 
>> ];
>> 
>> This works fine.
>> 
>> Occasionally, I am printing a log message, like so:
>> 
>> mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
>> pictures_path] ]; 
>> 
>> and then output that to whatever channel is active (screen or log file).
>> 
>> Now, in cases where pictures_path is still set to the default, 
>> the users sees some thing like:
>> 
>> /Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
>> 
>> which is confusing to the user (and takes up a lot of space).
>> 
>> How can I convert this back to the more human-readable /Users/xx/Pictures  
>> or ~/Pictures ?
>> 
>> I have checked NSURL's doc, but couldn't find a method to convert the path.
>> 
>> 
>> Hints will be appreciated.
>> Best, 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/admin.szatmari.net%40gmail.com
>> 
>> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How to convert path through container into standard form?

2022-12-11 Thread Sandor Szatmari via Cocoa-dev
-stringByAbbreviatingWithTildeInPath

First page in google results

> On Dec 11, 2022, at 15:06, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
> I have an NSURL * pictures_path;
> 
> By default, this is set to 
> 
>  pictures_path = [ [NSFileManager defaultManager] URLForDirectory: 
> NSPicturesDirectory
> inDomain: NSUserDomainMask
>appropriateForURL: nil create: NO error: 
> ];
> 
> This works fine.
> 
> Occasionally, I am printing a log message, like so:
> 
>  mesg = [[NSMutableString alloc] initWithString: [mainDirectoryLocation_ 
> pictures_path] ]; 
> 
> and then output that to whatever channel is active (screen or log file).
> 
> Now, in cases where pictures_path is still set to the default, 
> the users sees some thing like:
> 
>  
> /Users//Library/Containers/com.apple.ScreenSaver.Engine.legacyScreenSaver/Data/Pictures
> 
> which is confusing to the user (and takes up a lot of space).
> 
> How can I convert this back to the more human-readable /Users/xx/Pictures  or 
> ~/Pictures ?
> 
> I have checked NSURL's doc, but couldn't find a method to convert the path.
> 
> 
> Hints will be appreciated.
> Best, 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Auto-layout, Forcing a top-level view to hug its contents

2022-11-04 Thread Sandor Szatmari via Cocoa-dev

> On Nov 4, 2022, at 23:05, Steve Christensen via Cocoa-dev 
>  wrote:
> 
> The view hierarchy doesn’t go through a layout pass until after it is added 
> to a live view or window. At awakeFromNib time it’s still essentially a 
> snapshot of the layout in the nib since it hasn’t yet been inserted into the 
> “context” that will allow the layout engine to determine how big all the 
> views actually need to be.

Would an offscreen view or window allow it to be laid out and examine prior to 
insertion in a live view/window?  Assuming this was necessary… of course.


Sandor

> 
>> On Nov 3, 2022, at 5:39 PM, Eyal Redler via Cocoa-dev 
>>  wrote:
>> 
>> I have a view in a nib, the constraints are setup so that the view should 
>> expand/contract to fit the contents and the nib is localized for several 
>> languages. When I check the frame size of the view in awakeFromNib the size 
>> I get is the same as the size set in the nib.
>> I tried forcing the view to resize by calling layout but this didn't change 
>> the frame size.
>> Is there a way to force the view to resize, before putting it on the screen?
>> 
>> TIA
>> 
>> Eyal Redler
>> 
>> "If Uri Geller bends spoons with divine powers, then he's doing it the hard 
>> way."
>> --James Randi
>> www.eyalredler.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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Set focus on NSTextField in an NSMenuItem

2022-10-22 Thread Sandor Szatmari via Cocoa-dev
Status items used to be easy… sigh

Sandor

> On Oct 22, 2022, at 09:37, Richard Charles  wrote:
> 
> 
>> On Oct 21, 2022, at 8:32 PM, Richard wrote:
>> 
>> In Xcode 13 the Info.plist file is now created automatically using build 
>> settings. Set "Application is Agent (UIElement)" to Yes. However, this 
>> modified build setting never makes it into the app bundle Info.plist file.
> 
> 
> Apparently this works fine in Xcode 13 but it does not work in Xcode 14. The 
> correct Info.plist file is never generated.
> 
> // Building a macOS Menu Bar App
> // https://www.youtube.com/watch?v=CuMLpnjPr2Y
> // Mark 21:08 (add Application is agent (UIElement) Info.plist setting)
> 
> Richard
> 
___

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: Set focus on NSTextField in an NSMenuItem

2022-10-21 Thread Sandor Szatmari via Cocoa-dev
Try observing mouse events and calling 

[NSApplication activateIgnoringOtherApps:YES] 

In the mouse down event… that works for me… see Dragan’s plist settings for the 
correct way to remove from Dock et all…


Sandor
> On Oct 21, 2022, at 15:44, Richard Charles  wrote:
> 
> 
>> On Oct 21, 2022, at 6:57 AM, Sandor Szatmari via Cocoa-dev 
>>  wrote:
>> 
>> Understood.  I DON’t get the behavior your seeing where the menu closes.  
>> Perhaps because I’m calling it from a different point in code.  I am calling 
>> [NSApplication activateIgnoringOtherApps:YES] in my listener/observer to the 
>> mouseDown action.
> 
> 
> I made a test MenuBarApp. To get the main menu of the app to not show I had 
> to hide the running app. But when the app is hidden, the text field in the 
> menu of a status bar item will not accept responder events.
> 
> Perhaps you should try using a text field in a popover like spotlight search.
> 
> Richard
> 
___

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: Set focus on NSTextField in an NSMenuItem

2022-10-21 Thread Sandor Szatmari via Cocoa-dev
Drgan,

> 
> On Oct 21, 2022, at 05:37, Dragan Milić via Cocoa-dev 
>  wrote:
> 
> 
>> On 20. 10. 2022., at 01:22, Sandor Szatmari wrote:
>> I have a status item and in order to get it to show I have to call this in 
>> my code that orders in the view/window
>> [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]
>> I have no idea if this is the best way to accomplish this, but it works for 
>> me…
> 
> 
>> On 21. 10. 2022., at 04:49, Richard Charles  wrote:
>> In a macOS document based application I added a menu item to a submenu and 
>> set the view of the menu item to a NSTextField. This was done using 
>> Interface Builder. It works just fine.
> 
> Sandor, Richard… I know guys… Please read my latest reply in this thread and 
> the explanation why I couldn’t set the focus on a text field inside a menu.

Understood.  I DON’t get the behavior your seeing where the menu closes.  
Perhaps because I’m calling it from a different point in code.  I am calling 
[NSApplication activateIgnoringOtherApps:YES] in my listener/observer to the 
mouseDown action.

Sandor

> 
> 
> -- Dragan
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Set focus on NSTextField in an NSMenuItem

2022-10-19 Thread Sandor Szatmari via Cocoa-dev
Dragan,

> On Oct 19, 2022, at 15:46, Dragan Milić via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> On 19. 10. 2022., at 03:52, Eric Schlegel  wrote:
>> 
>> 
>> I can tell you that the Help menu does itself use makeFirstResponder: on the 
>> text view…
> 
> Eric, thanks for detailed explanation and willingness to help. Your message 
> triggered me to play with the issue a bit more and I figured out what the 
> problem is. But I also realised  I’ve come to some wrong conclusions before, 
> so I want to correct myself as well so that nobody here is left confused by 
> them. I’ll do that first…
> 
>> On 18. 10. 2022., at 18:43, Dragan Milić wrote:
>> 
>> This issue isn’t related to the menu being attached to the NSStatusItem, it 
>> also happens in the main and/or contextual menu within the application. I’d 
>> eventually want to set the focus on the text field programmatically each 
>> time the menu appears, but that’s not possible either.
> 
> This was something I observed quite some time ago and I admin I haven’t 
> confirmed it again before I sent my initial message here. God knows what I 
> did wrong at that time, but I can say my above statement is completely false! 
> Placing NSTextFiend inside NSMenuItem works fine in both main and contextual 
> menus in the application. The text field gets focus when the menu opens, 
> sending -[NSWindow makeFirstResponder:] is not even necessary.
> 
> Now, my problem is that the application is defined as LSUIElement=YES (or its 
> activation policy is programmatically set to 
> NSApplicationActivationPolicyAccessory), meaning it doesn’t show its icon in 
> the Dock, it doesn’t show its main menu, nor can it be made active with 
> alt+tab. As known, clicking the status item of any application and making its 
> status item menu visible, doesn’t really make the application active, and in 
> my case that affect functionality of the text item. So, when I click on the 
> status item and show the status item menu, the application is not really 
> active

I have a status item and in order to get it to show I have to call this in my 
code that orders in the view/window

[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]

I have no idea if this is the best way to accomplish this, but it works for me…

I can also add that status items used to be pretty easy to work with but Apple 
made this significantly harder over the years…. I see applications that have 
accompanying status items that work, better than mine… but I haven’t been able 
to figure it out any better than what I have…

Sandor

> and hence is text field (kind of) disabled, not being able to receive events. 
> If I set application’s activation policy to 
> NSApplicationActivationPolicyRegular and make it active (clicking on its icon 
> in the Dock or alt+tabbing) before I click its status item, the status item 
> menu appears with the text field active and focused, ready to be typed into.
> 
> I haven’t find the complete solution yet. Sending -[NSApp 
> activateIgnoringOtherApps:YES] does the job partially; clicking the status 
> item and opening its menu results in the application being activated, but 
> that automatically closes the menu immediately upon being open. But the 
> application stays active, so clicking the status item again finally opens the 
> menu with the text field active and having focus. If anyone have any idea how 
> to solve this, I’d be thankful to hear it.
> 
> -- Dragan
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Mystery interference with AirPlay

2022-06-15 Thread Sandor Szatmari via Cocoa-dev


> 
> On Jun 15, 2022, at 12:56, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I am using only:
> 
> o NSBeep()
> o NSSound
> 0 and link to these frameworks: CoreLocation, Foundation, Cocoa, ScreenSaver, 
> QuartzCore, ApplicationServices, AppKit, Photos, MediaLibrary, IOKit
> 
> Does any of those cause trouble?

If your app registers to play sound, which sounds like is happening without you 
intending it to, your app would ‘acquire’ the sound device and preempt other 
audio.  There are ways to play audio without preempting other audio sources, at 
least on the iPhone, Instagram will play sound with existing audio playback and 
not stop them. But that’s not the point just a curiosity.  Why would they do 
that?  Most use cases you want to preempt audio because listening to multiple 
sources of unrelated audio rarely makes sense… except for alerts and the like 
usually.

I can’t point you in the right direction but find out what is acquiring the 
audio device.  Start with your multimedia playback code.  What are you using to 
play the ‘video’?

Sandor

> 
> Best , G.
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Building for 10.12

2022-03-20 Thread Sandor Szatmari via Cocoa-dev
G

> On Mar 20, 2022, at 17:04, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> 
>>> My question now is: why did Xcode not warn me about that function, even 
>>> though the deployment target was set to 10.12 ?
>>The deployment target not a compiler setting. It is more of a runtime 
>> thing.  So if you set the deployment target to 13.0 it will not launch on 
>> macOS 12, for
> 
> Oh, I see. That explains a lot.
> 
>> example.  The SDK is what determines what API are (not) available. So if you 
>> were building against the 10.12 SDK you would have gotten a compiler error.
> 
> Sorry for asking (again?): how would I do that?
> How do I install old SDK's on current Xcode / macOS?
> 

You used to have to manually copy the SDKs into the Xcode app (where the SDKs 
are stored) then you have to edit a plist inside the app to let Xcode know what 
the min SDK is… not sure if this still works… but that should give you enough 
info to google an example or something… don’t mean to be vague, but I don’t 
have my work comp here to look at the paths and file locs… but you should be 
able to find an example 

> How would I tell Xcode to use those old SDK's?
> Is there an easy switch back and forth?
They show up in the Xcode UI… you will have access to all SDKs you put in the 
app…

Again not sure if this solution still works…. Good luck

Sandor
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Sandor Szatmari via Cocoa-dev
Alex,

> On May 9, 2021, at 15:15, Steve Mykytyn via Cocoa-dev 
>  wrote:
> 
> You're creating your own problem here.

Agreed, If you have control.  I would either make all top level objects arrays, 
or dictionaries.  If your writing the plist and its a dict, wrap it in an 
array, or vice versa, embed arrays in a dict with meta data keys, as suggested. 
 Of course, if you have the flexibility to do this.  

If not, I’d create a single point of access to read the plists and have logic 
inside to handle the non-homogeneous top level objects and return a consistent 
data structure for consumption.

Sandor

>  If you are controlling what the
> configuration plist is, make it a dictionary at the top level with three
> keys and entries:
> 
> idString - something that confirms to you that this is one of yours
> array - the array you want in some cases
> dictionary - the dictionary you want in some cases.
> 
> Then you deserialize it, confirm it's one of yours, and branch on which of
> the latter two keys is not null.
> 
> This kind of situation can arise if you are configuring multiple apps out
> of the same code base.
> 
> If you're not controlling the configuration plist, just use
> NSPropertyListSerialization as noted previously and branch on what you get.
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Sandor Szatmari via Cocoa-dev
Gabriel

> On Apr 3, 2021, at 10:55, Gabriel Zachmann  wrote:
> 
> 
>> 
>>> 
>>> [ [NSUserDefaults userDefaultsWithName:@"monitor-name"] boolForKey:@"some 
>>> key"]
>> 
>> I thought -addSuiteNamed: would allow you to maintain/add a suite of 
>> defaults for each monitor. 
> 
> Maybe.
> 
> The doc says:
> 
> """
> The suiteName domain is similar to a bundle identifier string, but isn't 
> necessarily tied to a particular application or bundle. A suite can be used 
> to hold preferences that are shared between multiple applications
> """
> 
> So, I think, it is meant for app groups.

App groups, I believe, were introduced in 10.7.   The -addSuiteNamed: API has 
been around since 10.0.  
> 
> What I don't get is this sentence in the doc:
> 
> "The additional search lists of the suiteName domain are searched after the 
> current domain..."
I believe that just means that your app’s Domain is searched first, and any 
common keys would mask out keys in your suite.  
> 
> And I'd rather understand exactly what my code is doing than guessing what it 
> might do.

Doesn’t seem mysterious… and would allow you to maintain a suite for each 
monitor type which could be loaded and unloaded as you detect the presence of a 
monitor, or based on which monitor your app is running on.  As long as your 
suite keys had a prefix they’d never collide with keys in you app’s main 
defaults domain.

Best Regards, Sandor

> 
> 
> 
> 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/archive%40mail-archive.com

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


Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Sandor Szatmari via Cocoa-dev
Gabriel,

> On Apr 3, 2021, at 07:41, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Thanks a lot for your response!
> 
>> User Defaults are now stored in an opaque in memory DB, and while the 
>> various files may still play a role, you can't make any assumptions about 
>> them anymore.
> 
> Yes, I understand that.
> 
>> That being said, [NSUserDefaults.standardUserDefaults boolForKey:@"some 
>> key"] etc should all work as expected.
> 
> Yes, they do.
> 
> But what I would like to have is a mechanism that lets me manage different 
> user defaults when the app is running on different monitors.
> Something like
> 
> [ [NSUserDefaults userDefaultsWithName:@"monitor-name"] boolForKey:@"some 
> key"]

I thought -addSuiteNamed: would allow you to maintain/add a suite of defaults 
for each monitor. 

Best regards, Sandor

> Best regards, Gabriel
> 
> PS:
> I used to be able to do something like that with a clutch using 
> ScreenSaverDefaults, but it seems like this has stopped working; I believe it 
> must have been one of the recent Catalina upgrades.
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Several different NSUserDefaults in the same app?

2021-04-02 Thread Sandor Szatmari via Cocoa-dev
Would suites work for you?

From the NSUserDefaults docs…

Maintaining Suites

- addSuiteNamed:
Inserts the specified domain name into the receiver’s search list.
- removeSuiteNamed:
Removes the specified domain name from the receiver’s search list.


Sandor Szatmari

> On Apr 2, 2021, at 17:05, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I used to manage different NSUserDefaults in my app depending on which 
> monitor it runs.
> So, I create filenames of the user defaults like this:
>  NSString * defaults_name = [ NSString stringWithFormat:@"de.zach.MyApp.%@", 
> displayname ];
> 
> Then I used to create the NSUserDefaults object with an unusual approach,
> but that does not seem to work any more.
> 
> So, I am wondering, what is the correct and easy approach to managing 
> different user settings (user defaults)?
> 
> Note that my app is sandboxed, so the user defaults must go in 
>  ~/Library/Containers/de.zach.MyApp/Data/Library/Preferences/
> , must they not?
> 
> I looked at -initWithSuiteName , but it seems to me that is not they proper 
> approach, is it?
> 
> Thanks a lot in advance for all kinds of insights and help!
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Drag-and-drop onto an NSTextField?

2020-08-01 Thread Sandor Szatmari via Cocoa-dev
I believe there were occasions where the UI was not updating, specifically the 
focus ring type behavior.  But that was implemented around 10.11 era, so maybe 
things have gotten better.

Sandor

> On Aug 1, 2020, at 13:04, Carl Hoefs  wrote:
> 
> I was wondering also about the necessity of:
> 
> [self setNeedsDisplay:YES];
> 
> It seems to work fine without it (perhaps it's already being done by the 
> superclass, NSTextField?).
> 
> -Carl
> 
> 
> 
>> On Aug 1, 2020, at 5:28 AM, Graham Cox  wrote:
>> 
>> You shouldn’t call -becomeFirstResponder yourself.
>> 
>> Instead, call [self.window makeFirstResponder:self].
>> 
>> That should properly switch the first responder, giving the previous 
>> responder the chance to refuse. Of course, that’s more obstructive if the 
>> previous responder DOES refuse, but that’s what they tell you to do (from 
>> the documentation on [NSReponder becomeFirstResponder]:
>> 
>>> Use the NSWindow makeFirstResponder: method, not this method, to make an 
>>> object the first responder. Never invoke this method directly.
>> 
>> 
>> —Graham
>> 
>> 
>> 
>>> On 1 Aug 2020, at 10:16 am, Sandor Szatmari via Cocoa-dev 
>>>  wrote:
>>> 
>>> I call…
>>> 
>>> [self becomeFirstResponder]
>>> [self setNeedsDisplay:YES]
>>> 
>>> Then return the drag operation required.
>>> 
>> 
> 
___

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: Drag-and-drop onto an NSTextField?

2020-08-01 Thread Sandor Szatmari via Cocoa-dev
Thanks Graham!  

Sandor

> On Aug 1, 2020, at 08:28, Graham Cox  wrote:
> 
> You shouldn’t call -becomeFirstResponder yourself.
> 
> Instead, call [self.window makeFirstResponder:self].
> 
> That should properly switch the first responder, giving the previous 
> responder the chance to refuse. Of course, that’s more obstructive if the 
> previous responder DOES refuse, but that’s what they tell you to do (from the 
> documentation on [NSReponder becomeFirstResponder]:
> 
>> Use the NSWindow makeFirstResponder: method, not this method, to make an 
>> object the first responder. Never invoke this method directly.
> 
> 
> 
> 
> —Graham
> 
> 
> 
>> On 1 Aug 2020, at 10:16 am, Sandor Szatmari via Cocoa-dev 
>>  wrote:
>> 
>> I call…
>> 
>> [self becomeFirstResponder]
>> [self setNeedsDisplay:YES]
>> 
>> Then return the drag operation required.
>> 
> 
___

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: Drag-and-drop onto an NSTextField?

2020-07-31 Thread Sandor Szatmari via Cocoa-dev
Took a bit to originally figure out but seems to me like it should be a 
default, or at least easily selectable behavior with an API.

Sandor

> On Jul 31, 2020, at 20:17, Carl Hoefs  wrote:
> 
> Sandor,
> 
> Ah! That's quite clever... and it works, too!
> 
> Thanks!
> -Carl
> 
> 
>> On Jul 31, 2020, at 5:16 PM, Sandor Szatmari  
>> wrote:
>> 
>> Carl,
>> 
>>>> On Jul 31, 2020, at 20:07, Carl Hoefs  
>>>> wrote:
>>>> 
>>> Hmm, subleasing NSTextField doesn't work for me (the dragged item gets 
>>> rejected). I've got the  protocol in my subclass of 
>>> NSTextField.
>>> 
>>> Is there something I need to set in -draggingEntered:?
>> 
>> I call…
>> 
>> [self becomeFirstResponder]
>> [self setNeedsDisplay:YES]
>> 
>> Then return the drag operation required.
>> 
>> Sandor
>> 
>>> I return NSDragOperationCopy.
>>> 
>>> Are there any other methods besides -draggingEntered: that must also be 
>>> overridden? 
>>> 
>>> -Carl
>>> 
>>> 
>>>> On Jul 31, 2020, at 4:49 PM, Sandor Szatmari 
>>>>  wrote:
>>>> 
>>>> For NSTexrField I have always created a subclass for my textfields
>>>> 
>>>> I call -registerForDraggedTypes: in -awakeFromNib in the subclass
>>>> 
>>>> And then to accept the drag implement the method in the sublclass
>>>> 
>>>>   -(NSDragOperation)draggingEntered:(id)sender
>>>> 
>>>> If there’s an easier or better it’d be cool to learn about it
>>>> 
>>>> Sandor
>>>> 
>>>>>> On Jul 31, 2020, at 19:29, Carl Hoefs via Cocoa-dev 
>>>>>>  wrote:
>>>>> 
>>>>> Why is drag-and-drop onto an NSTextField enabled only when it has focus? 
>>>>> 
>>>>> Is there any way around this?
>>>>> 
>>>>> -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/admin.szatmari.net%40gmail.com
>>>>> 
>>>>> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Drag-and-drop onto an NSTextField?

2020-07-31 Thread Sandor Szatmari via Cocoa-dev
Carl,

>> On Jul 31, 2020, at 20:07, Carl Hoefs  wrote:
> Hmm, subleasing NSTextField doesn't work for me (the dragged item gets 
> rejected). I've got the  protocol in my subclass of 
> NSTextField.
> 
> Is there something I need to set in -draggingEntered:?

I call…

[self becomeFirstResponder]
[self setNeedsDisplay:YES]

Then return the drag operation required.

Sandor

> I return NSDragOperationCopy.
> 
> Are there any other methods besides -draggingEntered: that must also be 
> overridden? 
> 
> -Carl
> 
> 
>> On Jul 31, 2020, at 4:49 PM, Sandor Szatmari  
>> wrote:
>> 
>> For NSTexrField I have always created a subclass for my textfields
>> 
>> I call -registerForDraggedTypes: in -awakeFromNib in the subclass
>> 
>> And then to accept the drag implement the method in the sublclass
>> 
>>   -(NSDragOperation)draggingEntered:(id)sender
>> 
>> If there’s an easier or better it’d be cool to learn about it
>> 
>> Sandor
>> 
>>>> On Jul 31, 2020, at 19:29, Carl Hoefs via Cocoa-dev 
>>>>  wrote:
>>> Why is drag-and-drop onto an NSTextField enabled only when it has focus?
>>> Is there any way around this?
>>> -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/admin.szatmari.net%40gmail.com
>>> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Drag-and-drop onto an NSTextField?

2020-07-31 Thread Sandor Szatmari via Cocoa-dev
For NSTexrField I have always created a subclass for my textfields

I call -registerForDraggedTypes: in -awakeFromNib in the subclass

And then to accept the drag implement the method in the sublclass

-(NSDragOperation)draggingEntered:(id)sender

If there’s an easier or better it’d be cool to learn about it

Sandor

> On Jul 31, 2020, at 19:29, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> Why is drag-and-drop onto an NSTextField enabled only when it has focus? 
> 
> Is there any way around this?
> 
> -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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Prevent screen saver from starting, but don't prevent computer sleep

2020-06-29 Thread Sandor Szatmari via Cocoa-dev
Gabriel,

> On Jun 29, 2020, at 07:04, Gabriel Zachmann  wrote:
> 
> 
>> I was hoping to convey to the OP that the goals of this question might have 
>> unintended consequences.
> 
> 
> I realize there might be security concerns with what I am trying to do.
> 
> Is there a way to lock the screen such that the user has to provide their 
> password to unlock it,
> and still have my app run fullscreen on the display?
> (similar to what happens when the screensaver is running)

I can’t remember if you are Sandboxing or not… but, if not, look at 
https://developer.apple.com/documentation/security/authorization_services

Otherwise, if sandboxing, refer to this discussion.
https://stackoverflow.com/questions/21956946/authenticate-user-objective-c-cocoa-sandboxing
> 
> 
> 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/archive%40mail-archive.com

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


Re: Prevent screen saver from starting, but don't prevent computer sleep

2020-06-29 Thread Sandor Szatmari via Cocoa-dev


> On Jun 29, 2020, at 02:46, じょいすじょん  wrote:
> 
> 
> 
>>> On Jun 29, 2020, at 15:24, Sandor Szatmari  
>>> wrote:
>>> 
>>> 
>>> 
>>>> On Jun 28, 2020, at 22:29, じょいすじょん via Cocoa-dev 
>>>>  wrote:
>>> 
>>> One way to do this is with the command line tool:
>>> caffeinate
>>> 
>>> You could run a background task that starts it with something like 
>>> caffeinate -dimsu
>>> 
>>> You can probably also find its source code on opensource.apple.com to 
>>> understand what it does and how.
>>> 
>>> Like here is a version:
>>> 
>>> https://opensource.apple.com/source/PowerManagement/PowerManagement-637.20.2/caffeinate/caffeinate.c.auto.html
>>> 
>>> You certainly still want a user to approve things.
>> 
>> I would say that if the user has the checkbox selected in system preferences 
>> that ties sleep/screensaver to security (prompt for password on 
>> sleep/screensaver activation) they have already answered this question.  In 
>> this situation any app that calls caffeinate in the background (or uses an 
>> API) to circumvent this security settings without informing the user should 
>> be considered dubious at best and perhaps even malware.  In effect this is 
>> disabling that security choice.  If the user has not selected this setting 
>> in system prefs then there is no issue preventing screensaver from 
>> activating.  I’d recommend this criteria for the basis of whether to 
>> interfere with normal system operations.
>> 
>> Sandor
> 
> Nobody said circumvent anything.
I know you didn’t say circumventing.  But, what is being asked is how to 
prevent screen saver from kicking in.
> I believe a user would have to authorize an NSTask or similar usage anyway, 
> unless they have disabled SIP.
Yes. This would inform the user.  That would be nice.
> I just provided reference to a tool that is already built and bundled that 
> does this (less code) and the source to that tool (inspiration for other 
> code).
Yes, agreed…
> I will not make any claims as to how that works with sandboxing. I 
> whole-heartedly expect and want any such functionality to be made clear to 
> users.
Yes, you did make that clear.  I was hoping to convey to the OP that the goals 
of this question might have unintended consequences.
> That said, it is easy to understand loads of legitimate use-cases for this.
Yea, agreed…

Sandor
> 
___

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: Prevent screen saver from starting, but don't prevent computer sleep

2020-06-29 Thread Sandor Szatmari via Cocoa-dev


> On Jun 28, 2020, at 22:29, じょいすじょん via Cocoa-dev  
> wrote:
> 
> One way to do this is with the command line tool:
> caffeinate
> 
> You could run a background task that starts it with something like 
> caffeinate -dimsu
> 
> You can probably also find its source code on opensource.apple.com to 
> understand what it does and how.
> 
> Like here is a version:
> 
> https://opensource.apple.com/source/PowerManagement/PowerManagement-637.20.2/caffeinate/caffeinate.c.auto.html
> 
> You certainly still want a user to approve things.

I would say that if the user has the checkbox selected in system preferences 
that ties sleep/screensaver to security (prompt for password on 
sleep/screensaver activation) they have already answered this question.  In 
this situation any app that calls caffeinate in the background (or uses an API) 
to circumvent this security settings without informing the user should be 
considered dubious at best and perhaps even malware.  In effect this is 
disabling that security choice.  If the user has not selected this setting in 
system prefs then there is no issue preventing screensaver from activating.  
I’d recommend this criteria for the basis of whether to interfere with normal 
system operations.

Sandor

> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Prevent screen saver from starting, but don't prevent computer sleep

2020-06-28 Thread Sandor Szatmari via Cocoa-dev
G,

> On Jun 28, 2020, at 15:31, Gabriel Zachmann  wrote:
> 
> 
>>> Does anyone know how to programmatically disable macOS from launching the 
>>> screen saver on macOS?
>>> I would like to do that in one of my apps.
>> 
>> Not sure in general, but in a managed host situation this type of system 
>> modification could be disallowed by policy.  Even admin users of a managed 
>> system can be barred from changing settings like these as they can affect 
>> security, eg when passwords must be prompted.  You wouldn’t want any person 
>> to be able to walk by and quit your app and have access to the user’s files.
> 
> Yes, agreed.  That is why I would like to disable ONLY the screensaver, 
> NOT System Preferences / Security / Require password ...
The ability to disable the screensaver timeout/activation can be blocked by 
policy.  On a system configured this way, the only way to change this setting 
is from the OpenDirectory server or the policy server.  Any attempt to change 
screensaver timeout/activation settings locally, by you (your software) or even 
an admin user with physical access to the system can be disallowed.  

Sandor

> 
> Ideally, my app could bring up the password prompt itself before quitting.  
> Is that possible?
> 
> 
> 
> 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/archive%40mail-archive.com

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


Re: Prevent screen saver from starting, but don't prevent computer sleep

2020-06-27 Thread Sandor Szatmari via Cocoa-dev
G,

> On Jun 27, 2020, at 12:47, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Does anyone know how to programmatically disable macOS from launching the 
> screen saver on macOS?
> I would like to do that in one of my apps.

Not sure in general, but in a managed host situation this type of system 
modification could be disallowed by policy.  Even admin users of a managed 
system can be barred from changing settings like these as they can affect 
security, eg when passwords must be prompted.  You wouldn’t want any person to 
be able to walk by and quit your app and have access to the user’s files.  
Anyway, probably not an issue for the majority of your users, but something to 
thing about…

Sandor

> 
> Note that I do NOT want to disable screen sleep, nor system sleep.
> I just want to set the idle time to "Never" , which you would do manually by 
> going 
> to System Preferences / Desktop & Screensaver / Start after ...
> 
> Basically, what I'd like to do in my app is what I can do using this on the 
> command line:
> 
>  defaults -currentHost write com.apple.screensaver idleTime
> 
> but I want to do it in my app. 
> And, of course, I'd like to restore the former setting when my app quits.
> 
> My app does not use a lot of compute resources, and it is perfectly fine if 
> and when the Mac goes to sleep after the idle time set in System Preferences 
> / Energy Saver / Turn display off after ...
> 
> I googled a lot , but I only found hints at using the function
> IOPMAssertionCreateWithName(); however, this does not seem to provide an 
> option for the screen saver.
> It seems to me it's just useful to turn off computer sleep.
> 
> Also, I found the tool caffeinate, but, again, this seems to me the wrong 
> utility, because it is all about computer sleep, too.
> 
> Any ideas or suggestions would be highly appreciated.
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Launching in fullscreen gives "Funk" sound sometimes

2020-06-24 Thread Sandor Szatmari via Cocoa-dev
G,


> On Jun 24, 2020, at 12:57, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> 
>> Set a symbolic breakpoint on NSBeep and see whether it’s your code that’s 
>> calling it.
>> 
> 
> Thanks, but how would I do that?
> I never use NSBeep in my code ..
The system is calling NSBeep
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Screensaver can capture mouse events under Catalina

2020-05-26 Thread Sandor Szatmari via Cocoa-dev
Gabriel,

> On May 26, 2020, at 04:21, Gabriel Zachmann  wrote:
> 
> Thanks a lot for your response!
> 
> Unfortunately, with -addGlobalMonitorForEventsMatchingMask: ,
> the event is still passed on to the higher-up objects, so that makes the 
> screensaver engine terminate the screensaver immediately.

Does this mean you’re unable to set up a global event tap/monitor?  If you are 
able, how are you setting it up?

Sandor

> 
> Best regards, Gabriel
> 
> 
> 
>> On 26. May 2020, at 00:54, Sandor Szatmari  
>> wrote:
>> 
>> Gabriel,  (this is a dup reply, forgot to cc list)
>> 
>> How are you setting up you global event monitor? 
>> 
>> I use this to handle catching mouse moved event when my app is not in the 
>> foreground…. maybe you use something like this
>> Just watch out for a lot of events and making your app a CPU hog.
>> 
>>   [NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMovedMask
>>  handler:
>>^(NSEvent * _Nonnull event)
>>{
>>   // Do stuff to handle events that I care about
>>}];
>> 
>> Sandor
> 
___

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: Screensaver can capture mouse events under Catalina

2020-05-25 Thread Sandor Szatmari via Cocoa-dev
Gabriel,  (this is a dup reply, forgot to cc list)

How are you setting up you global event monitor? 

I use this to handle catching mouse moved event when my app is not in the 
foreground…. maybe you use something like this
Just watch out for a lot of events and making your app a CPU hog.

[NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMovedMask
   handler:
 ^(NSEvent * _Nonnull event)
 {
// Do stuff to handle events that I care about
 }];

Sandor

> On May 25, 2020, at 18:35, Michael Diehr via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> On May 25, 2020, at 12:43 PM, Gabriel Zachmann  wrote:
>> [...]
>> Unfortunately, it seems that I still cannot get key events.
>> Best regards, Gabriel
> 
> I tried what feels like a thousand different variations and could not get key 
> events under Catalina screensaver.  
> If you can figure it out, please do share!
> Mike
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Xcode Archive builds Debug version?

2020-05-24 Thread Sandor Szatmari via Cocoa-dev
Gabriele,

When you do archive Xcode uses a different build destination.  It seems to use 
/Library/Developer/Xcode/Archives 

It builds an Archive bundle of sorts to package your build.

You can right click in the organizer and select ‘Show In Finder’ and explore 
what Xcode is building for you.  I suspect it should be correct.

Sandor

> On May 24, 2020, at 04:47, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> When I do Product / Archive , Xcode builds my app and shows it in the 
> Organizer.
> However, it only creates /tmp/Debug, even though the Scheme has Build 
> Configuration = Release in the Archive section.
> (I have set Derived Data to /tmp in the Locations tab in Xcode's preferences.)
> 
> I am confused: does Xcode really build the debug version when I make an 
> Archive?
> (which I need for signing and notarizing)
> Or does it build the Release version and - erroneously - puts it in 
> /tmp/Debug?
> 
> Either way I would like to correct that and sort things out.
> 
> Could some kind should please shed some light on this?
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How to save a window's position and size

2020-05-23 Thread Sandor Szatmari via Cocoa-dev
Gabriel,

> On May 23, 2020, at 15:54, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Actually, after observing the new behavior for a while, 
> I have to say it's "almost" perfect.
> 
> The window still opens at some funny position with a smallish size (where is 
> that stored?),
> but with no content, just grey inside, for a split second,
> then it snaps to the autosaved position/size.
> 
> It's OK, but is there a way to make it appear directly at the autosaved 
> position?
> 
> Best regards, Gabriel
> 
> 
> PS:
> For reference, this is what I do in AppDelegate's 
> applicationDidFinishLaunching:
> 
> - (void) applicationDidFinishLaunching: (NSNotification *) aNotification
> {
>[self.window setDelegate: self]; 
> 
>self.masterViewController = [[MasterViewController alloc] initWithNibName: 
> @"MasterViewController" bundle: nil];
> 
>[self.window.contentView addSubview: self.masterViewController.view];
>self.masterViewController.view.frame = ((NSView*) 
> self.window.contentView).bounds;
>[self.window makeFirstResponder: self.masterViewController.view];
> 
>[self.window setFrameAutosaveName: @"myApp"];

‘myApp’ may just be obfuscated from your real value, but I tend to give windows 
save keys unique names so that as an app grows the defaults are easily readable 
and there are no collisions.

Sandor

> }
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Concurrent loading of images ?

2020-05-08 Thread Sandor Szatmari via Cocoa-dev

> On May 8, 2020, at 15:13, Rob Petrovec via Cocoa-dev 
>  wrote:
> 
> 
> 
>>> On May 8, 2020, at 12:19 PM, Jens Alfke via Cocoa-dev 
>>>  wrote:
>>> 
>>> 
>>> 
 On May 8, 2020, at 9:53 AM, Gabriel Zachmann via Cocoa-dev 
  wrote:
>>> 
>>> So, I was thinking, maybe it helps to load the next image concurrently, 
>>> while the current one is still being displayed.
>> 
>> Sure. Just be aware that if you're using NSImage, simply loading an NSImage 
>> does not rasterize it; the class tries to be 'lazy' about doing work. So 
>> your background task should explicitly render it, e.g. into an 
>> NSBitmapImageRep.
>> 
>>> I also read about the GCD's dispatch queues, but it seems to me that this 
>>> would not be the suitable approach since I always only have one task 
>>> running concurrently to the main thread.
>> 
>> Why not? Dispatch queues are always available. (The main thread is simply a 
>> special queue.) You can run the background task by creating a single 
>> dispatch queue and then using dispatch_async to call a block that does the 
>> work. The end of the block would call dispatch_async back to the main queue 
>> and pass the image as a parameter.
>I second the use of GCD.  Its also considerably simpler than NSThread, 
> NSOperationQueue/NSOperation et al.  This is the kind of operation that GCD 
> was invented for.

I would add, that for a long running process, open ended work, or task, I would 
favor a thread.  But for short and finite items I would favor 
GCD/NSOperationQueue.  

Are you going to only load one image, the next image, in this concurrent 
loading scenario?  Or, will you be loading many images and caching them?  

I would imaging looking one or two ahead would be the choice.  I’m just trying 
to understand the need/use case.  If there’s lots of overhead that can be 
reduced to a one time effort than maybe a thread is better.  If not maybe a 
one-off throw-it-in-a-queue and be done with it approach is better?

Sandor

> 
> —Rob
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Xcode Build Location

2020-05-08 Thread Sandor Szatmari via Cocoa-dev
Richard,

> On May 8, 2020, at 10:16, Steve Mills via Cocoa-dev 
>  wrote:
> 
> On May 8, 2020, at 09:08:17, Richard Charles via Cocoa-dev 
>  wrote:
>> 
>> Some of the dynamically linked libraries are large. If they are put in a 
>> workspace with the main project then it is so large it becomes cumbersome to 
>> work with.
>> 
>> One library has over 1,100 source files. Using a workspace for this 
>> collection of projects on a daily basis is not fun at all. It is actually 
>> counter productive.
> 
> I have a feeling you're misunderstanding workspaces. You keep all the 
> projects in their own projects, but you simply add each project to the 
> workspace. The projects still manage the individual subproject files.

We have a ton of source files, 6 or more frameworks, 15+ apps/targets, use one 
Workspace for all of these, and have Xcode set to use legacy build locations 
(which is the build directory within the project directory).  This setup is 
quite responsive and intelligently builds only what is necessary based on ‘what 
is dirty’.  This is on Xcode 9.4.1 (I know, 9.X, I’m working on it, haha)

But either your codebase significantly larger or more complicated, or something 
else is going on.  I hope you can get workspaces… well… working.  They have 
been an improvement for us in many ways.

Sandor

> 
>> So maybe I have answered my own question. The string appears to remain 
>> constant as long as the project name and enclosing folder remain unchanged. 
>> So perhaps there is nothing to be afraid of here with regards to this string 
>> being part of a link path during build.
> 
> Yes, don't worry about any folder names Xcode creates when you let it manage 
> the build location. It won't be part of any paths written to final frameworks 
> or anything like that. Xcode knows what it's doing.
> 
> BTW, this discussion should really be in the xcode-users list, or better yet 
> in the newer xcode list at apple-dev.groups.io.
> 
> --
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


[OT] Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Sandor Szatmari via Cocoa-dev
Alex,

> On Apr 29, 2020, at 17:12, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> Not sure about this, but in Objective-C, you’re not supposed to start 
> methods with new.

I’ve always operated under the premise that using a reserved prefix, such as 
new, was not verboten.  Rather, if one chose the prefix new one must ensure 
that the method followed memory management conventions, and would return an 
object with a +1 retain count.  Am I mistaken about this?

Sandor

> 
>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>>  wrote:
> 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];
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


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

2020-04-24 Thread Sandor Szatmari via Cocoa-dev
Allan,

> On Apr 24, 2020, at 00:14, Allan Odgaard via Cocoa-dev 
>  wrote:
> 
> On 24 Apr 2020, at 9:51, Gary L. Wade wrote:
> 
>> Have you tried a speed check with just iCloud turned off but internet on?
> 
> I have tried with iCloud disabled, internet disabled, and SIP disabled.

Have you tried something like the Little Snitch app to Confirm there is network 
access to Apple and determine what network activity is going on?

Sandor
> 
> Only the latter two removes the delay. Also, the issue happens for 
> ~/Downloads which is not an iCloud folder.
> 
> Furthermore, the stack dump seems fairly clear about what goes on.
> 
> For the records, I’m reposting my findings here with stack dump.
> 
> This is actually from Transmission.app, in Preferences you can configure 
> download folders, so I selected ~/Documents, ~/Downloads, and ~/Desktop, 
> which are the 3 “protected” folders. I then ran a spindump when opening 
> Preferences, which has to obtain display name and icon for these folders (to 
> show in the UI), which results in 620 ms spent in NSWorkspace’s iconForFile: 
> (getattrlist).
> 
>62   -[NSWorkspace iconForFile:] + 80 (AppKit + 3229058) [0x7fff32ee1582]
>62   -[NSWorkspace _iconForURL:] + 100 (AppKit + 3229205) [0x7fff32ee1615]
>62   _GetIconRefFromURL + 26 (LaunchServices + 233122) [0x7fff370edea2]
>62   BindingManager::CreateWithURL(__CFURL const*, bool) + 28 
> (LaunchServices + 233204) [0x7fff370edef4]
>62   BindingBlueprint::BindingBlueprint(__CFURL const*) + 78 
> (LaunchServices + 233350) [0x7fff370edf86]
>62   BindingBlueprint::copyURLProperties(__CFURL const*) + 50 
> (LaunchServices + 233496) [0x7fff370ee018]
>62   CFURLCopyResourcePropertiesForKeys + 111 (CoreFoundation + 555324) 
> [0x7fff3599493c]
>62   _FSURLCopyResourcePropertiesForKeysInternal(__CFURL const*, __CFArray 
> const*, void*, __CFError**, unsigned char) + 1110 (CoreServicesInternal + 
> 60765) [0x7fff4ecb0d5d]
>62   prepareValuesForBitmap(__CFURL const*, __FileCache*, 
> _FilePropertyBitmap*, __CFError**) + 363 (CoreServicesInternal + 17604) 
> [0x7fff4eca64c4]
>62   __getattrlist + 10 (libsystem_kernel.dylib + 5746) [0x7fff6fa19672]
>*62  hndl_unix_scall64 + 22 (kernel + 819718) [0xff80002c8206]
>*62  unix_syscall64 + 647 (kernel + 7894519) [0xff80009875f7]
>*62  getattrlist + 136 (kernel + 3512472) [0xff8000559898]
>*62  ??? (kernel + 3512820) [0xff80005599f4]
>*62  ??? (kernel + 3501529) [0xff8000556dd9]
>*62  ??? (kernel + 3490836) [0xff8000554414]
>*62  mac_vnode_check_access + 154 (kernel + 9093082) [0xff8000aabfda]
>*62  hook_vnode_check_access + 167 (Sandbox + 39552) [0xff7f823a7a80]
>*62  sb_evaluate + 5004 (Sandbox + 67658) [0xff7f823ae84a]
>*62  approval_response_wait + 142 (Sandbox + 154851) [0xff7f823c3ce3]
>*62  __WAITING_ON_APPROVAL_FROM_SANDBOXD__ + 23 (Sandbox + 155134) 
> [0xff7f823c3dfe]
>*62  ??? (kernel + 6855402) [0xff8000889aea]
>*62  thread_block_reason + 175 (kernel + 1317935) [0xff8000341c2f]
>*62  ??? (kernel + 1324017) [0xff80003433f1]
>*62  machine_switch_context + 200 (kernel + 2388456) [0xff80004471e8]
> 
> Looking at sandboxd, it has 3 queues spending respectively 150, 160, and 310 
> ms in TCCAccessPreflightWithAuditToken (so total time spent there is 620 ms), 
> which I would guess is processing Transmission’s request for reading the 
> extended attributes for the 3 paths.
> 
> But sandboxd itself does tccd_send_message, so it seems to call upon the tccd 
> daemon.
> 
> There are two tccd instances running on my system, each have two queues with 
> 150 ms spent in SecCodeCheckValidityWithErrors (so a total of 600 ms spent in 
> tccd).
> 
> This code though again seems rely on another process by calling: 
> securityd_send_sync_and_do (which does XPC).
> 
> But I can’t find out which process it communicates with. I don’t know if this 
> could be launched-on-demand and therefore not part of the spindump report?
> 
> But to summarize, first call of getattrlist/getxattr for a protected folder 
> seems to trigger application signature validation (makes sense), which, at 
> least on my system, appears to involve network access, reminiscent of what 
> goes on with execve().
> 
> Given the above, I don’t think anyone can dispute that this is what goes on, 
> and it would be extremely strange if this is not “by design”.
> 
> What might be a bug is that the check does network access, but you don’t just 
> put such code in by mistake, so obviously there must be certain times where 
> it needs network access, and as demonstrated with execve(), Apple is not shy 
> of making low-level system APIs contact Apple’s servers as part of their SIP.
> 
> The million dollar question is now: What are the conditions under which it 
> must have network access? and/or why does it seem to trigger all the time on 
> my system?
> 

Re: Open a panel in secondary thread?

2020-03-23 Thread Sandor Szatmari via Cocoa-dev

> On Mar 23, 2020, at 10:01 AM, Gabriel Zachmann  wrote:
> 
> 
 I would not do this.  It is widely documented that AppKit API that produce 
 UI elements, like NSOpenPanel, are _not_ thread safe.  
>>> 
>>> Right, and that is why I have to execute any UI code in the main thread,
>>> or so I thought.
>>> As far as I understand, the dispatch_get_main_queue is executed by the main 
>>> thread, isn't it?
>> Yes
> 
> So, why is 
>dispatch_sync( dispatch_get_main_queue(),  block opening a NSOpenPanel )
> a bad idea?
I think it’s fine if the following is true… you are ok with blocking your 
secondary thread while the user interacts with the panel.
> 
>>> 
>>> When the user selects a directory, I collect all files in that sub-tree 
>>> (aka "scan").
>>> That might involve aliases. which means I need to ask the user to open the 
>>> directory that alias points to.
>>> Because that scan can take several seconds (10-20),
>>> I wanted to do that scan in a secondary thread so that it can update 
>>> progress info in the UI.
>> 
>> This is all reasonable…  I guess there may be two options, ask the user on 
>> the main thread, before you are on your background thread,
> 
> Would be doable, but would complicate the code, because
>  
> I would first need to scan the whole directory tree for aliases,
I haven’t had much experience with needing to request permission to access 
files, but I thought you’d have to ask permission before scanning.  Are you 
allowed to scan before you ask for permission?

> get user permission ,
> then pass the array of directories to a secondary thread.
> 
> Also, I would like to give the user progress info while the secondary thread 
> is collecting.
Yes, understood.  Does the user have to ask for this process to begin, or does 
it start automatically?  Is the user allowed to interact with the app while 
this is going on, or does the UI just update with progress?

Sandor
> 
>> and only start the background thread after the user answers, or dispatch the 
>> UI work to the main thread from your background thread as your code sample 
>> showed.
> 
> So my solution is viable ?
> 
> 
> 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/archive%40mail-archive.com

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


Re: Open a panel in secondary thread?

2020-03-23 Thread Sandor Szatmari via Cocoa-dev
Gabriel,

> On Mar 23, 2020, at 8:54 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Thanks a lot for your response.
> 
>> I would not do this.  It is widely documented that AppKit API that produce 
>> UI elements, like NSOpenPanel, are _not_ thread safe.  
> 
> Right, and that is why I have to execute any UI code in the main thread,
> or so I thought.
> As far as I understand, the dispatch_get_main_queue is executed by the main 
> thread, isn't it?
Yes
> 
> 
>> So you may find your app hitting some memory stomping issues or strange 
>> crashes/exceptions due to this.  Specifically what problems you will hit are 
>> anyones guess, but its just a matter of time.  There is a reason Xcode has 
>> the Main Thread Checker to catch UI elements being used on secondary threads.
>> 
>> Lets come at  this from a different direction: What are you trying to do? 
>> Why do you think you need to use the open panel on a secondary thread?
> 
> When the user selects a directory, I collect all files in that sub-tree (aka 
> "scan").
> That might involve aliases. which means I need to ask the user to open the 
> directory that alias points to.
> Because that scan can take several seconds (10-20),
> I wanted to do that scan in a secondary thread so that it can update progress 
> info in the UI.

This is all reasonable…  I guess there may be two options, ask the user on the 
main thread, before you are on your background thread, and only start the 
background thread after the user answers, or dispatch the UI work to the main 
thread from your background thread as your code sample showed.

The fact you have to block (dispatch_sync) your background thread sort of leads 
me to think you could be avoiding the extra care needed to run things on the 
main thread by calling in before you start your background thread.

Sandor

> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Open a panel in secondary thread?

2020-03-22 Thread Sandor Szatmari via Cocoa-dev

> On Mar 22, 2020, at 6:20 PM, Steve Mills via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> On Mar 22, 2020, at 15:38, Rob Petrovec via Cocoa-dev 
>>  wrote:
>> 
>> I would not do this.  It is widely documented that AppKit API that produce 
>> UI elements, like NSOpenPanel, are _not_ thread safe.
> 
> The code shown *is* threadsafe. It’s calling it on the main thread.
The only issue I see is that if this code were ever called on the main thread.  
I don’t know if this is likely because we don’t know enough about the OP’s 
code.  But if there is a chance a simple test would suffice.

if ( [NSThread isMainThread] )
   // call code directly
else
   // call dispatch_sync(…)

Sandor

> 
> Steve via iPad
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Open a panel in secondary thread?

2020-03-21 Thread Sandor Szatmari via Cocoa-dev
You must run the panel on the main thread.

Sandor

> On Mar 21, 2020, at 3:05 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Is it possible to open an NSOpenPanel in a secondary thread?
> 
> I create the thread like this:
> 
>directoryScanThread_ = [[NSThread alloc] initWithTarget: self
>   selector: 
> @selector(scanDirectory:)
> object: nil];
>[directoryScanThread_ start];
> 
> 
> But when I do:
> 
>NSOpenPanel *oPanel = [NSOpenPanel openPanel];
> 
> it crashes at this point.
> 
> In the docs, I found a hint that one should use
> 
>lockFocusIfCanDraw
> 
> but that is deprecated now.
> 
> Any ideas will be highly appreciated.
> 
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Confusion about screen resolution

2020-02-22 Thread Sandor Szatmari via Cocoa-dev

> On Feb 22, 2020, at 12:30, Ken Thomases via Cocoa-dev 
>  wrote:
> 
> On Feb 22, 2020, at 9:02 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
>> 
>>> 
>>> No, the default on recent Macs is scaled to slightly under 2x.
>>> 
>> 
>> It is about ~ 1.7 .
>> 
>> this means that every view has to be scaled by this odd factor, before 
>> writing its contents into the frame buffer.
>> I am curious as to why that doesn't cause any aliasing artefacts, or 
>> anti-aliasing artefacts ...
> 
> For Retina displays, the backing store's size is always 2x the size in points 
> that Cocoa reports.  The backing store is then scaled to the display's 
> physical resolution.
> 
> Also, even if though the default point-size-to-display-physical-pixels used 
> to be 2x, remember that other scaling was always supported.  The fact that 
> the default has changed doesn't introduce a *new* problem.  Apple always had 
> to have a solution for this.

Does it make sense that starting at 1.7 gives you a 0.3 headroom for ‘zoom’ 
without having to upsample?

Sandor
> 
> Regards,
> Ken
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Sorting an array

2020-02-11 Thread Sandor Szatmari via Cocoa-dev
Gabriel,


> On Feb 11, 2020, at 10:36, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have some trivial questions regarding sorting a simple array of strings.
> 
> I used to use this code:
> 
>NSSortDescriptor *sd = [[NSSortDescriptor alloc] initWithKey: nil 
> ascending: YES];//TODO: raus
>[imagefiles_ sortUsingDescriptors: @[sd] ];

Personally I find it awkward to use a sort descriptor with an explicitly nil 
key.  The API allows it, but it just feels off to me.  Are you restricted to 
using an SDK that doesn’t have the 
-sortedArrayUsingComparator:^NSComparissonResult block parameter?  If so, the 
selector based API is still pretty clean.  Before the block version of the API 
we often wrote our own sort methods and used them as the selectors sorting.  
Way back, we implemented Cocoa NaturalLanguage sorting for a long time like 
this, by wrapping C API in Cocoa.  I mention this just to illustrate that you 
can do a lot this way.

But ultimately the sorting API you choose should depend on the content of the 
array.

Sandor

> 
> where imagefiles_ is an NSMutableArray* .
> 
> Now, in the developer doc
> ( 
> https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Collections/Articles/Arrays.html#//apple_ref/doc/uid/2132-SW5)
>  
> I saw a different method. Following that, I was thinking of sorting my array 
> like this:
> 
>NSArray * sorted_images = [imagefiles_ sortedArrayUsingSelector: 
> @selector(localizedStandardCompare:) ];
>imagefiles_ = [NSMutableArray arrayWithArray: sorted_images];
> 
> First of all, what are the advantages/disadvantages of either method?
> 
> Second, I was wondering if I could write the second method like this:
> 
>imagefiles_ = [imagefiles_ sortedArrayUsingSelector: 
> @selector(localizedStandardCompare:) ];
> 
> 
> Thanks a lot in advance.
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: How to check whether directory tree has changed?

2019-12-21 Thread Sandor Szatmari via Cocoa-dev

> On Dec 21, 2019, at 13:43, Jens Alfke  wrote:
> 
> 
> 
>> On Dec 21, 2019, at 10:18 AM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> Right.  I was hoping there is an easy way to do this.
>> Something like a recursive check sum over the whole directory tree that the 
>> OS might keep.
>> I don't want to do a complete tree traversal every time the app launches.
> 
> I think you'll need to do it yourself. The FSEvents API isn't going to keep 
> an infinitely long history; it certainly won't go back to before the time the 
> OS booted.

Yea, the documentation does a good job describing what the circumstances are 
that are not covered. 
> 
> You can shorten the traversal by keeping the mod date of every directory. 
> Then if the mod date hasn't changed, you don't need to scan the directory 
> contents.
> 
> You can keep the data set smaller by keeping only a hash of the collected 
> names/mod dates/sizes of the files in each directory. But you do need to keep 
> the info for each subdirectory to do the above optimization.
> 
> —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/archive%40mail-archive.com

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


Re: How to check whether directory tree has changed?

2019-12-21 Thread Sandor Szatmari via Cocoa-dev

> On Dec 21, 2019, at 12:56, Gabriel Zachmann  wrote:
> 
> 
> Thanks a lot!
> 
> Does it really watch subfolders, too?

The docs can answer this better I.

> 
> Also, it seems to me like it works only while the program is running.
> 
> I am mostly interested in changes that happen "behind the program's back",
> i.e., while it is *not* running.

If your code is not running what is looking for changes?
Are you looking to detect changes that happen in between launches of your app?  
If so you’d have to save state and compare that saved state to the dir contents 
each time the app is launched.  I’d just use a directory enumerator for this.  
Then you can use the dispatch stuff to monitor while running.

Sandor

> Does your code really handle that?
> 
> Best regards, Gabriel
> 
> 
>> I’ve used dispatch stuff.  I found this with a quick google… it should be 
>> close to what one would need to monitor a folder.
>> int fildes = open("/path/to/directory", O_RDONLY);
>> 
>> dispatch_queue_t queue = 
>> dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
>> dispatch_source_t source = 
>> dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fildes, 
>> DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | 
>> DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, queue);
>> 
>> dispatch_source_set_event_handler(source, ^{
>> // ... handle changes
>> });
>> 
>> dispatch_source_set_cancel_handler(source, ^{
>> // ... handle cancel
>> });
>> 
>> dispatch_resume(source); // Start monitoring
>> 
>> // And sometime later
>> dispatch_source_cancel(source); // Stop monitoring
> 
___

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 check whether directory tree has changed?

2019-12-21 Thread Sandor Szatmari via Cocoa-dev

I’ve used dispatch stuff.  I found this with a quick google… it should be close 
to what one would need to monitor a folder.
int fildes = open("/path/to/directory", O_RDONLY);

dispatch_queue_t queue = 
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, 
fildes, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | 
DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, queue);

dispatch_source_set_event_handler(source, ^{
// ... handle changes
});

dispatch_source_set_cancel_handler(source, ^{
// ... handle cancel
});

dispatch_resume(source); // Start monitoring

// And sometime later
dispatch_source_cancel(source); // Stop monitoring

> On Dec 21, 2019, at 11:08, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Is there a quick and easy way to check whether or not a directory tree has 
> changed?
> 
> I am only interested in file additions or deletions, somewhere beneath a 
> specific root directory,
> e.g., ~/Data/some_directory.
> 
> However, I am interested in such changes between different invocations of my 
> program.
> So, when the user adds a file somewhere in the directory tree while my 
> program is not running, I'd still like to detect that.
> 
> Is there a quick and easy way to do this?
> 
> Thanks a lot in advance.
> Best regards, Gabriel
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Catalina scroll view issues

2019-12-19 Thread Sandor Szatmari via Cocoa-dev
Eyal,

> On Dec 19, 2019, at 02:55, Redler Eyal via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> Since you’re using CoreGraphics, it’s very likely there’s an edge case with 
>> your customers’ systems that you aren’t encountering.  CG is pretty much the 
>> lowest practical level in the graphics stack. Since your app does reproduce 
>> the issue but in other configurations than yours, you could still add it, 
>> but if you can include the system configuration data from About This Mac and 
>> data files from those affected customers, as well as screen shots, it can 
>> help. You might be asked for a sysdiagnose after the problem happens, so 
>> consider asking your customers to provide that as well.
> 
> OK, I'll try to get the sysdiagnose from my users before submitting. I must 
> say I'm really skeptic regarding the relation with my use of CG. It is not 
> that CG is not used by CT and everything else is also using CG.

CG may not be the issue… and I cannot offer a better suggestion, but when I 
rule out a possibility without proof, it usually turns out that I over look the 
solution to the problem.  Good luck!

Sandor

> The way it looks it seems very much related to the scrolling mechanism, the 
> pre-rendered portion is not rendered but for some reason the scrolling 
> mechanism thinks that it is. I really don't see how a core-graphic issue, and 
> certainly not a misuse on my part could cause a view to be partially rendered.
> BTW, do you think this type of issue is appropriate for a DTS incident?
> 
>> Here’s the developer release notes for Catalina:
>> https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes
> 
> Thanks. I saw that but I recall that in the past you used to have app-kit 
> specific release notes which were usually more detailed. 
> 
>> As an aside, it would be helpful to know why you chose CG for text 
>> rendering. CT has gotten better with RTL and bidi text, but if you saw 
>> particular issues there, reports about those can help everyone.
> 
> When I started developing this app (2002), there was no choice other then CG 
> since core text didn't exist and the other technologies didn't support Hebrew 
> and RTL well, if at all. So I wrote my own text engine and this was very good 
> for me commercially as my app was the the first and only word-processor to 
> support Hebrew (and later Arabic) properly on Max OS X. I had a similar 
> experience with OpenType which was not initially supported and that also gave 
> me an edge. As time passed Apple did improve the RTL support and was offering 
> more APIs so theoretically I could have rewritten my code to use the new APIs 
> but in reality I actually did the opposite and relied less on Apple's APIs 
> (for example, parsing 'cmap' tables) because there were always bugs and even 
> regressions which could render my app unusable upon an OS upgrade. Beyond the 
> bugs, I think my RTL is better, or at least as far as I'm concerned as a 
> native Hebrew speaker and having such low-level control over something that 
> is core to my app is essential IMO.
> 
> Eyal Redler
> 
> "If Uri Geller bends spoons with divine powers, then he's doing it the hard 
> way."
> --James Randi
> www.eyalredler.com
> 
> 
> 
> 
> 
> 
>> Gary L. Wade
>> http://www.garywade.com/
>> 
 On Dec 17, 2019, at 2:12 AM, Redler Eyal  wrote:
>>> 
>>> I am drawing using core graphics. I tried turning copiesOnScroll and this 
>>> didn't seem to help.
>>> 
>>> I'll gladly write a feedback report but I'm not able to reproduce this so I 
>>> can't give an xcode project that will reproduce this... Isn't that a 
>>> requirement?
>>> 
>>> BTW, perhaps you know: Are there no release notes for app kit with 
>>> Catalina? All I can find are very general notes without mention of any 
>>> specific API. I could not find, for example, any mention of the deprecation 
>>> of copiesOnScroll and what it means (is is not always on, always off etc)
>>> 
>>> Thanks,
>>> 
>>> Eyal
>>> 
 On 16 Dec 2019, at 16:07, Gary L. Wade  
 wrote:
 
 If you’re not involving a higher level class like NSTextView or a medium 
 level one like CoreText, it sounds like you might be going all the way 
 down to CoreGraphics? If so, you might find your disparity between your 
 system and your users in things like retina choice for a particular 
 display and changes with respect to layers, especially things like the 
 copiesOnScroll. If these don’t lead you to a solution where you say, “Oh, 
 I really should’ve done this rather than that,” (20/20 hindsight) then 
 write up a feedback report and add its URL here.
 --
 Gary L. Wade
 http://www.garywade.com/
 
> On Dec 16, 2019, at 1:03 AM, Redler Eyal via Cocoa-dev 
>  wrote:
> 
> Thanks!
> I don't use CoreText or NSTextView. I pretty much ruled out RTL vs LTR 

Re: i386 Deprecated Warning in Xcode 9.4.1

2019-10-25 Thread Sandor Szatmari via Cocoa-dev
Jens,

Thanks for your response, it’s good advice.  But, doesn’t get me anywhere 
unfortunately.  See below…

> On Oct 24, 2019, at 15:57, Jens Alfke  wrote:
> 
>> On Oct 24, 2019, at 11:46 AM, Sandor Szatmari via Cocoa-dev 
>>  wrote:
>> 
>> Is there a flag I can set in Xcode to squash these?
> 
> If these are compiler (Clang) warnings, then:

Not sure, here is the alert text in its entirety.

warning: The i386 architecture is deprecated for your deployment target (macOS 
10.6). You should update your ARCHS build setting to remove the i386 
architecture.

And yes, deployment of 10.6 is correct.  Haha  We only ‘ship’ software 
internally and support a wide variety of systems integrations that require 
older tech.  Hopefully, some of our customers will feel they’ve gotten enough 
ROI on there investments and drop the legacy stuff we have to support 
eventually.

Sandor

> 
> 1. Right-click on a warning in the Xcode issues browser
> 2. Select "Show In Log" — this should take you to the build log with that 
> warning message visible
> 3. At the end of the warning message should be something like 
> "(-Wsomething)", which is the name of the Clang compiler flag that enables 
> that warning.
> 4. Go to your target build settings, and in the custom warning flags add 
> "-Wno-something", which will suppress that warning.
> 
> —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/archive%40mail-archive.com

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


i386 Deprecated Warning in Xcode 9.4.1

2019-10-24 Thread Sandor Szatmari via Cocoa-dev
Migrating some code to 64 bit…

Making a pit stop at Xcode 9.4.1/32 bit as the last stable 32 bit build.  

40+ projects with multiple targets make for a lot of i386 is deprecated noise.  
I’d like to silence these warnings while I straighten out actual issues.

Is there a flag I can set in Xcode to squash these?

Much thanks in advance,
Sandor
___

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 for Swift

2019-10-15 Thread Sandor Szatmari via Cocoa-dev
I always felt that swift was introduced to allow the development ecosystem to 
grow and intended to be a language that eliminated some of the squishiness of 
Objective-C.  My opinion is that this was intended to make Apple’s job of code 
review and approval easier and more concrete (business case?).

I like what Swift promised, but it comes with a ton of syntactic baggage.  

Objective-C is simple, there is a low bar to pick it up and run.  But you need 
to adhere to mutually agreed ‘contracts’.  This takes an investment of time.  
And what is time? $$$  and still there’s no guarantee.

Swift is complicated and enforces all the contracts itself, syntactically.  
This was intended to yield good code without the need for ‘seasoning’ the 
developer.  As was aptly put, you need to get on board and learn everything 
upfront.

To me, the difference is philosophical… oohm  If Swift solves your problems the 
high bar to learn and the oppressive syntactical nature becomes a small price 
to pay.  It will be less philosophical when Apple stops releasing new feature 
support in Obj-C to force everyone over to Swift.  In my opinion this is the 
direction, we’ll see if we get there.  Apple loves the soft roll out.  Think 
about the recent Carbon/Cocoa discussion.

Obj-C represents the freedom for me to write bad code if I need to… this never 
happens, right?  But honestly, I don’t have enough Swift experience to know if 
you can write bad Swift code.

Anyways, I still prefer Obj-C.

Sandor

> On Oct 15, 2019, at 04:59, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> 
>> On Oct 15, 2019, at 1:37 AM, Quincey Morris via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> The really important thing about using Swift is that you *have to* learn to 
>> change the way you think about dealing with nil values. 
> 
> And it’s a fucking cumbersome pain in the ass.  Simply converting between 
> floats and integers that might be nil is an unwieldy pain in the ass.  
> 
> It’s a cumbersome and time wasting pain in the ass.  And I’ve been doing this 
> for well over a year too.  
> 
> Here’s the dangerous area.  What I have seen is that Swift lets you do stupid 
> shit in new and more complicated ways so that you need your most expensive 
> people to spend an extraordinary time debugging the problems created by your 
> most junior people.  Why?  Because they are doing things the new Swifty way, 
> that’s why?!  And because someone wrote an article and published it on the 
> Internet, so it must be a good idea!
> 
> Like my problems with VIPER.  Our team has (against my direction) protocol 
> backed every class within our implementation of the VIPER pattern creating 
> monstrous retain cycles so that EVERY one of our 120+ screens NEVER gets 
> released.  And with protocols and their strong variables backing every object 
> that confirms to them, it’s murder figuring which variables to turn weak in 
> the conforming classes and god forbid that the protocols are not class backed 
> or you’ll get yet another bizarre compile error.
> 
> Also, if everything is a class extension, then nothing is.  But at least it 
> makes nice little separator lines in the menus just like pragma mark - used 
> to in Objective-C.
> 
> Swift is one big steaming pile of suck.  It lets those who don’t know any 
> better think that they do and then with that hubris, go on and create very 
> Swifty nightmares.  Our iOS feature tests still rebooted the Mac or crashed 
> the user session back to login as of mid last week.  
> 
> You really need to feel the joy of debugging 3,410 retain cycles - in VIPER, 
> with many interdependent classes conforming to multiple protocols that all 
> have strong vars, sometimes with vars directly assigned to a protocol.
> 
> Yes, you read that right, 3,410 retain cycles.  I have freaking 24 node 
> cycles and enough chained multi node retain loops that they are organic 
> chemistry moledules.  Thankfully, I’m down to our last 300
> 
> Rant off.
> 
> Lovely pics of retain cycles for you all to enjoy.  These are the easy ones.
> 
> https://imgur.com/a/pC3p9A5
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: xCode troubles

2019-05-14 Thread Sandor Szatmari
Peter,

> On May 14, 2019, at 06:39, Peter Hudson  wrote:
> 
> Hi All
> 
> xCode has just decided ( for the 20th time this week ) that I don’t deserve 
> any UI tools in Interface Builder - as in the panel on the right hand side of 
> the main window.  I have tried everything I can think of to try to get them 
> back - like restarting xCode, opening different files etc.

Did you try trashing Xcodes preferences?

Sandor
> But alas, no GUI tools for me !
> 
> Any ideas on how to fix this would be most welcome.
> 
> MacOS 10.14.3 / xCode 10.2 / swift project for macOS
> 
> 
> Peter
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Need a direction. App crash in CoreData while loading a window's nib

2018-11-04 Thread Sandor Szatmari
If you can, can you establish the binding programmatically after launch?  If 
so, does the program crash once the bindings are re-established?  … considering 
if it is a launch issue or more systematic? 

Sandor

> On Nov 4, 2018, at 17:25, Motti Shneor  wrote:
> 
> Well, thanks Dave, Hunter, Richard and the rest.
> 
> I followed each of your suggestions, and I finally found the culprit. 
> 
> A single binding, rather a nifty one, which I don’t know how to do better — 
> Maybe you can help.  Removing this binding (alas losing functionality) window 
> opens instantly, regardless of the number of items.
> 
> First off — the issue is NOT in any of the table columns. They do have 
> complicated bindings, but all work fast and fine.
> 
> In the .xib  there is also a custom view, only used as an accessory view to 
> an NSAlert dialog, when user choses to perform special editing on the items 
> displayed. (Kind of search-and-replace action).
> 
> In that view, there’s a popup button, populated by binding to a (quite 
> special) array controller. That array controller’s content-array has the 
> binding that breaks window loading.
> 
> I’ll try to explain: 
> 
> This NSTable in the window displays a list of all “Measurement” entities 
> related to a specific “Sample” (the “representedObject” of the File’s owner). 
> For that I have a “Measurements Array Controller” in “Entity” mode, whose 
> content array is bound to File’s Owner’s “representedObject.measurements” 
> relation. All table columns are bound to that array controller.
> 
> Now each Measurement is connected via to-one relation to a “Species” entity. 
> 
> In my custom view,  I wish to populate a popup button with all the Species 
> entities which appear in the displayed Measurements.
> 
> For that, I created the “Used Species Array Controller” whose section in the 
> .xib appears below:
> 
> 
>  automaticallyPreparesContent="YES" preservesSelection="NO" 
> selectsInsertedObjects="NO" avoidsEmptySelection="NO" 
> clearsFilterPredicateOnInsertion="NO" automaticallyRearrangesObjects="YES" 
> id="syR-1c-VXy" userLabel="Used Species Array Controller">
>
> BAD:   keyPath="arrangedObjects.@distinctUnionOfObjects.species" id="TQk-n5-RYc”/>
>keyPath="representedObject.managedObjectContext" id="Vqg-dg-DdM"/>
>keyPath="sortDescriptors" id="3uW-GQ-bKN"/>
>
> 
> 
> 
> The “Bad” binding destination, is the Measurements Array Controller’s 
> “arrangedObjects”, and the model keyPath is “@distinctUnionOfObjects.species”
> 
> Effectively, when calculated, this “collects” all the species from all 
> displayed measurements, removing any duplicates. Nifty, isn’t it?
> 
> I can’t provide the list statically, in advance, because the user is free to 
> replace the species of displayed measurements - and although this is rather 
> “heavy” binding - I can’t see anything “recursive” about it, or otherwise 
> iteratively-dependent. I would guess this ArrayController should “Prepare” 
> its content array once - and forget about it, until time any of the 
> Measurements (arrangedObjects) mutate.
> 
> I know this isn’t easy to grasp… but any idea for how to improve this will be 
> greatly appreciated.
> 
> Thanks again! 
> 
> Motti Shneor
> ---
> Ceterum censeo Microsoftinem delendam esse
> 
> 
>> On 4 Nov 2018, at 21:41, Dave Fernandes  wrote:
>> 
>> 
>> 
>>> On Nov 4, 2018, at 2:24 PM, Motti Shneor  wrote:
>>> 
>>> Hi Dave and thanks for the reply.
>>> 
>>> As you can see in the stack - there isn’t actually any “code” per-se that 
>>> runs at that time. Here is the actual method that fails:
>>> 
>> 
>>> As for modifying the persistent store - I guess I don’t because the 
>>> database-document does not become “dirty”. If I double click one of the 
>>> “sample” entities that can be open - and the window is shown as expected, 
>>> then I close the document - there are no autosaves or changes recorded. The 
>>> modification time of the persistent store does not change.
>>> 
>>> However - you’re right to point at 
>>> NSManagedObjectContextDidChangeNotification — how could I get it to pop? 
>> 
>> Set up an observer for that notification for your MOC and set a breakpoint 
>> in that observer.
>> 
>>> 
>>> 3 of my NSTableColumn do have a formatter for the number presented - but 
>>> why should this affect the context, The columns are not “editable” 
>>> in-place. 
>> 
>> Just trying to narrow this down without assuming too much.
>> 
>>> 
>>> I will attempt to delete these columns and try again… 
>>> 
>> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.com

Re: XPC Question

2018-10-23 Thread Sandor Szatmari

> On Oct 23, 2018, at 02:56, Uli Kusterer  wrote:
> 
>> On 18. Sep 2018, at 19:25, Alastair Houghton  
>> wrote:
>> Well, Cocoa has Distributed Objects, which you could use for this purpose.  
>> DO has some interesting behaviour (in particular, watch out - it can throw 
>> exceptions, even when calling methods that don’t normally do so), but it 
>> does let you send messages to objects fairly easily over a network.
> 
> From what I remember, DO also has some very ... interesting behaviour when it 
> comes to time-outs, and predictable timing, as well as dropped connections. 
> Basically, it mostly assumes a stable, near-instant network, and there's no 
> good way to recover from a dropped network, and no control over how long it 
> will take to recover from stalls etc. either.
> 
> In short, DO is intended for small LANs, so if you're planning to use it over 
> the internet ... don't.

Thanks, yes, I agree.  DO should only be considered for LAN operations.  Apt 
descriptions of its limitations and implementation restrictions.  We have had 
several 24/7 systems running, synchronized via DO since forever.  It is very 
reliable when done right.  If not, it can be a mess.

> If you need a fairly painless way for network communication, I'd suggest 
> creating your own mechanism on top of queues of message objects and keyed, or 
> better secure, archiving. You can always model things after XPC, with the 
> same method names etc.


This will, again, be for a controlled environment (local LAN).  Not sure what 
direction I’ll go at this point, but at least with the feedback I’ve gotten I 
can design something knowing I am not overlooking a newly introduced macOS 
native inter-machine RPC technology.

Thanks for your thoughts,
Sandor

> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
> 
___

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: XPC Question

2018-09-18 Thread Sandor Szatmari
Alistair,

> On Sep 18, 2018, at 13:25, Alastair Houghton  
> wrote:
> 
>> On 18 Sep 2018, at 16:48, Sandor Szatmari  
>> wrote:
>> 
>> Thanks Alistair!
>> 
>> Anyone else have additional info?
> 
> Well, Cocoa has Distributed Objects, which you could use for this purpose.  
> DO has some interesting behaviour

Yes, we have several DO apps.  We’ve used DO for 10+ years for LAN based peer 
to peer solution on in house apps.  I am looking to implement some new 
functionality and wanted to stay away from deprecated technology if I can.  So, 
I was looking at newer solutions so as to not reinvent the wheel.  So it 
appears that XPC is only like interprocess DO, and is unable to do 
inter-machine RPC.  Ok, thanks!  And quite a nice breakdown of the RPC bone 
yard.  Hearing CORBA takes me back down memory lane.  :) 

Thanks again for your time and thoughts!  

Sandor 


> (in particular, watch out - it can throw exceptions, even when calling 
> methods that don’t normally do so), but it does let you send messages to 
> objects fairly easily over a network.  There’s also Sun RPC (which uses the 
> rpcgen tool, which you can find documented here: 
> <https://docs.oracle.com/cd/E19683-01/816-1435/rpcgenpguide-24243/index.html>).
>   Both of those are built-in to the macOS.
> 
> There are other options too, but they’ll be more work; for instance CORBA, 
> DCE RPC (or indeed DCOM, which is based on it), SOAP, XML-RPC, or a Restful 
> HTTP(S) interface.  Or, indeed, a custom TCP-based server.
> 
> Exactly what you use depends on what’s best for your use case, which you 
> don’t describe.  In particular, cross-platform support is a major driver 
> here; if you use DO, you probably won’t find it easy to talk to Windows or 
> Linux machines if you ever need to in the future, and while Sun RPC is easy 
> on most UNIX systems, Windows uses DCE RPC.  CORBA is probably only of 
> interest if you’re trying to talk to some enterprise system already built 
> with it.  SOAP, XML-RPC and Restful HTTP(S) are fairly general purpose and 
> might be good choices if you ever wanted to talk to a server built with (say) 
> Python or Ruby.
> 
> Anyway...
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net
> 
___

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: XPC Question

2018-09-18 Thread Sandor Szatmari
Thanks Alistair!

Anyone else have additional info?

Sandor

> On Sep 18, 2018, at 08:59, Alastair Houghton  
> wrote:
> 
>> On 18 Sep 2018, at 13:37, Sandor Szatmari  
>> wrote:
>> 
>> Can you do XPC RPC over an IP connection?  Or, in other words… Can you do 
>> XPC between two computers?
> 
> Not as far as I’m aware. As far as I know, XPC is built on top of Mach 
> messaging, which in theory can be used across the network but IIRC the 
> version of Mach used in Darwin doesn’t support it.
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net
> 
___

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


XPC Question

2018-09-18 Thread Sandor Szatmari
Can you do XPC RPC over an IP connection?  Or, in other words… Can you do XPC 
between two computers?

Thanks,
Sandor
___

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 if /Network/Library is available

2018-09-04 Thread Sandor Szatmari
OK inertia overcome…  I tested FSEvents and if I create an event stream for 
/Network and restrict to mount and I unmount flags I can successfully detect 
the mounting and in mounting of these shares.  I appreciate your thoughts!  
Thanks for your help.

Sandor

> On Sep 3, 2018, at 14:51, Sandor Szatmari  
> wrote:
> 
> Thanks for your thoughts!  
> 
> Below vvv
>> On Sep 3, 2018, at 13:14, Jean-Daniel  wrote:
>> 
>> 
>> 
>>> Le 3 sept. 2018 à 19:07, Sandor Szatmari  a 
>>> écrit :
>>> 
>>> I have a problem to solve where it appears I need to detect if 
>>> /Network/Library is available or not.  
>>> 
>>> Basically, I’d like to handle situation where I need to copy items from 
>>> /Network/Library at times when it’s it’s not yet available but may be 
>>> available soon…  i.e. at boot, or after the Network cycles, etc.
>>> 
>>> There’s a couple of strategies I can think of:
>>> 
>>> Keep failing the copy until it works or a default time out expires
>>> Notification of availability (Preferred, but I can’t find a way to do this)
>>> Quit and retry later.
>>> 
>>> Any suggestion/guidance anyone can provide on this?
>> 
>> I’m not familiar with /Network/Library, but if this is a standard directory, 
>> you can wait for it to be created using file system event (I think there is 
>> a node dispatch source for that), and if this is a mount point, you can use 
>> disk arbitration framework to get notification.
> 
> /Network/Library is a special directory published by OSX server that allows 
> you to share a common ‘Library’ folder to the clients on your LAN.  As an 
> example of its special behavior, it appears as a directory even when not 
> available.  (It probably is a directory itself).  It is created once and does 
> not go away, like /Volumes.  I am trying to detect the presence of files 
> within it or whether it’ is ‘mounted’.  When it’s not available ‘ls -al’ 
> responds with ‘ls: Host not available’.  And when it is available ‘ls -al’ 
> responds with directory contents as expected.  I can use this behavior to 
> implement the keep trying while failure and not timed out approach.
> 
> I have looked at FSEvents and Disk arbitration already and I’m not sure I can 
> use these as it does seem to have special treatment. I hope I can use one of 
> them.  I tried NSWorkspace (disk mount/in mount notifications) and these 
> didn’t seem to be triggered.  
> 
> Sandor
> 
>> 
___

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 if /Network/Library is available

2018-09-03 Thread Sandor Szatmari
Thanks for your thoughts!  

Below vvv
> On Sep 3, 2018, at 13:14, Jean-Daniel  wrote:
> 
> 
> 
>> Le 3 sept. 2018 à 19:07, Sandor Szatmari  a 
>> écrit :
>> 
>> I have a problem to solve where it appears I need to detect if 
>> /Network/Library is available or not.  
>> 
>> Basically, I’d like to handle situation where I need to copy items from 
>> /Network/Library at times when it’s it’s not yet available but may be 
>> available soon…  i.e. at boot, or after the Network cycles, etc.
>> 
>> There’s a couple of strategies I can think of:
>> 
>> Keep failing the copy until it works or a default time out expires
>> Notification of availability (Preferred, but I can’t find a way to do this)
>> Quit and retry later.
>> 
>> Any suggestion/guidance anyone can provide on this?
> 
> I’m not familiar with /Network/Library, but if this is a standard directory, 
> you can wait for it to be created using file system event (I think there is a 
> node dispatch source for that), and if this is a mount point, you can use 
> disk arbitration framework to get notification.

/Network/Library is a special directory published by OSX server that allows you 
to share a common ‘Library’ folder to the clients on your LAN.  As an example 
of its special behavior, it appears as a directory even when not available.  
(It probably is a directory itself).  It is created once and does not go away, 
like /Volumes.  I am trying to detect the presence of files within it or 
whether it’ is ‘mounted’.  When it’s not available ‘ls -al’ responds with ‘ls: 
Host not available’.  And when it is available ‘ls -al’ responds with directory 
contents as expected.  I can use this behavior to implement the keep trying 
while failure and not timed out approach.

I have looked at FSEvents and Disk arbitration already and I’m not sure I can 
use these as it does seem to have special treatment. I hope I can use one of 
them.  I tried NSWorkspace (disk mount/in mount notifications) and these didn’t 
seem to be triggered.  

Sandor

> 
___

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


Detecting if /Network/Library is available

2018-09-03 Thread Sandor Szatmari
I have a problem to solve where it appears I need to detect if /Network/Library 
is available or not.  

Basically, I’d like to handle situation where I need to copy items from 
/Network/Library at times when it’s it’s not yet available but may be available 
soon…  i.e. at boot, or after the Network cycles, etc.

There’s a couple of strategies I can think of:

 Keep failing the copy until it works or a default time out expires
 Notification of availability (Preferred, but I can’t find a way to do this)
 Quit and retry later.

Any suggestion/guidance anyone can provide on this?

Thanks in advance,
Sandor
___

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 Sandor Szatmari
I have done stuff like this just using NSTextField.  You can connect delegate 
methods to supply the array of suitable strings to select from that match the 
‘prefix’ the user types in.  For every character the user types I recalculate 
the array of completions.  You can filter a very long list of completions very 
quickly.  I don’t have the code in front of me but I can post something 
tomorrow if this sounds like an avenue you haven’t considered yet.

I think it was a combination of:

-controlTextDidChange:

-(NSArray *)control:(NSControl *)control textView:(NSTextView *)textView 
completions:(NSArray *)words forPartialWordRange:(NSRange)charRange 
indexOfSelectedItem:(NSInteger *)index

I found that the non obvious part was setting the pointer ‘index’ to -1 or 
something like that to indicate that no selection was made yet.  This caused 
the entire list of possible completions to be presented. Then everything worked 
as expected.  If you know the index of the string you want to autocomplete to 
you set ‘index’ to that, well…, index.

Sandor

> On Jul 25, 2018, at 18:56, Keary Suska  wrote:
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Deleting files extremely slow since OSX High sierra

2018-04-25 Thread Sandor Szatmari
On Apr 25, 2018, at 12:00, Rob Petrovec  wrote:

>> On Apr 25, 2018, at 9:32 AM, Vojtěch Meluzín  
>> wrote:
>> apple forcing devs to change stuff all the time (wasting our time) is just 
>> sad
>FSDeleteObject was deprecated in 10.8. That was 5 releases & 5 years ago.  
> So I don’t know what you mean by “forcing devs to change stuff all  the 
> time”.  You’ve had 5 years to update your code.  They also haven’t killed the 
> API yet.  It still works, just slower then you would like.  

We just recently replaced all the FS…Object code we had.  We waited for the 
API/behavior to mature.  There was a lot of churn with Unix permissions, ACLs, 
attributes… etc.  We found that the change started on 10.8 but didn’t quite 
stabilize until 10.11.  

On the 10.11 SDK we were able to get identical if not better attribute 
preservation and better performance as well.  

Am I wrong in remembering that the FS…Object API is not 64bit compatible?  

Sandor

> You can’t expect them to keep a deprecated API running perfectly in 
> perpetuity.  That would be silly and a waste of Apple’s engineering 
> resources.  Its time for you to poop or get off the pot, so to speak.
> 
> 
>> On Apr 25, 2018, at 10:45 AM, MeldaProduction  
>> wrote:
>> If you have a function to "delete a
>> file", it will still be a function to delete a file, there's no
>> improvement! Apple is simply covering badly designed APIs, which do work,
>> they are far from ideal, but they work
>Its not a design issue here.  FSDeleteObject uses FSRef’s.  FSRefs were a 
> big improvement over FSSpecs from back in the day, but FSRefs have been 
> deprecated in favor of URLs for years.  URLs are leaps and bounds better then 
> FSRef’s.  So that is what Apple improved by introducing new API that uses 
> URLs and deprecating the older FSRef equivalents.
> 
> 
>> On Apr 25, 2018, at 10:25 AM, Dave  wrote:
>> Well if you consider the use of “gasoline” as an “update” on steam power,
>Fine, then use solar power vs coal, Calculators vs an Abacus, or a MacBook 
> Pro vs a IBM 026  Keypunch (google it) 
> as an analogy.  They all apply just as well.
> 
> 
>>> On Apr 25, 2018, at 11:45 AM, David Young  wrote:
>> 
>> This hateful stuff doesn't really belong on this list, does it?
>Agreed.
> 
> —Rob
> 
> 
>> On Apr 25, 2018, at 9:32 AM, Vojtěch Meluzín  
>> wrote:
>> 
>> Thanks Mike,  i'll probably try. I am reluctant to do that, because api is
>> api and apple forcing devs to change stuff all the time (wasting our time)
>> is just sad. Plus i just cannot imagine how it could cause things to be
>> that bad. And finally people here seem to report general problems... Well
>> apple... Anyways i'll try.
>> 
>> Cheers!
>> Vojtech
>> www.meldaproduction.com
>> 
>> Dne po 23. 4. 2018 13:36 uživatel Mike Throckmorton <
>> mike1throckmor...@gmail.com> napsal:
>> 
>>> Try replacing FSDeleteObject with [[NSFileManager defaultManager]
>>> removeItemAtPath: pth error: ];
>>> 
>>> Worked for me.
>>> 
>>> Delete of folder containing 7500 files went from reay slow down to
>>> nice and quick.
>>> 
>>> I also found that other older FSRef based api's got slow.
>>> 
>>> Sandboxing? Discouraging use of elderly API's?
>>> 
>>> Time to ditch the old stuff anyway.
>>> 
>>> Vojtûch Meluzín Sunday, April 22, 2018 9:55 PM
>>> 
 Hi,
 
 I have a custom installer, which places various audio plugins (bundles)
 onto the target system and as an uninstaller it removes them. It manages
 them the same way as any other folder (containing folders and files).
>>> Since
 OSX High sierra deleting these files became extremely slow, almost like
>>> the
 OSX is checking the bundles after every change. On some computers it also
 blocks write access to the files inside these bundles (e.g. if the
 installer is used again). It almost seems like some pseudosecurity
>>> measure
 gone wrong, not the first time on OSX after all...
 
 Any ideas what is going on? For the record I'm using FSDeleteObject to
 delete files/folders, I know deprecated, but I don't see a reason for
 messing up with new API if the old one works.
 
 Thanks in advance.
 Vojtech
 ___
 
 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/mike1throckmorton%40gmail.com
 
 This email sent to mike1throckmor...@gmail.com
>>> ---
>>> Mike Throckmortonmike1throckmor...@gmail.com
>>> Software Engineer
>>> My Mac 

Re: file encription/decriptoin iOS

2017-06-28 Thread Sandor Szatmari
I thought there were both local and iCloud Notes, no?

Sandor

> On Jun 28, 2017, at 09:14, Jean-Daniel <mail...@xenonium.com> wrote:
> 
> 
>> Le 27 juin 2017 à 04:25, Sandor Szatmari <admin.szatmari@gmail.com> a 
>> écrit :
>> 
>> This is an interesting thread.  The OP's original question made me think of 
>> the functionality Apple recently (how recently I'm not sure) added to the 
>> iOS Notes app.  It allows you to selectively 'encrypt' (password protect) a 
>> note.  This functionality allows you to pass your phone to someone to let 
>> them read a note and not worry about them skipping to your note with all 
>> your 'secret info'.  Also, if someone got your phone in an unlocked state, 
>> (it could happen I guess) they couldn't trust a Mac and browse to plain text 
>> files.  
> 
> Notes are sync with iCloud and can be read on a Mac where this is far more 
> common to share a session.
> 
>> I must say at this point I whole heartedly agree with all the warnings for 
>> implementing encryption schemes.  But is there not also a valid use case 
>> here?  Unless I'm misunderstanding things, Apple seemed to think so.
>> 
>> Sandor
>> 
>>>> On Jun 26, 2017, at 13:59, Jens Alfke <j...@mooseyard.com> wrote:
>>>> 
>>>> 
>>>> On Jun 26, 2017, at 9:50 AM, Alex Zavatone <z...@mac.com> wrote:
>>>> 
>>>> You can use the iExplore app to look in the Documents folder of any device 
>>>> you attach to your Mac. 
>>> 
>>> But you can only attach a device to your Mac if the device is unlocked, 
>>> since you have to OK the “Do you trust this computer?” alert.
>>> As recent court cases have shown, unlocking an iOS device against the 
>>> owner’s will is nearly impossible.
>>> 
>>>> Also, data protection SUCKS because it locks the files if the app goes in 
>>>> to the background, basically suspending any file based background 
>>>> operations like sql db updates. 
>>> 
>>> It does this by default, but you can alter those settings if you need 
>>> background access to certain files, basically trading some security for 
>>> greater access.
>>> 
>>>> Thanks to the help of Chris Thorman, I was able to update an AES256 hmac 
>>>> method to work with UTF-8 char sets.  We use this for data security over 
>>>> http.
>>> 
>>> It’s much easier to just enable SSL/TLS on the HTTP server. (Though I 
>>> realize there are cases where you don’t have control over the server, or 
>>> circumstances prevent deploying HTTPS.)
>>> 
>>>> Now, it might be overkill or just bad design, but we use a CoreData db 
>>>> with transformable property and encrypt the data stored. 
>>> 
>>> How do you store the encryption key? That’s often the downfall; even if you 
>>> put it in the Keychain, it can be accessed by an attacker if your app’s 
>>> files are accessible (unless you add TouchID authentication to it.)
>>> 
>>> (Also, I hope you’re using a different IV for each record you encrypt. 
>>> Sorry to be a broken record about this, but it’s important.)
>>> 
>>> —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/admin.szatmari.net%40gmail.com
>>> 
>>> This email sent to admin.szatmari@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/mailing%40xenonium.com
>> 
>> This email sent to mail...@xenonium.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: file encription/decriptoin iOS

2017-06-27 Thread Sandor Szatmari
Jens,



Sandor
> On Jun 27, 2017, at 01:24, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Jun 26, 2017, at 7:25 PM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> This is an interesting thread.  The OP's original question made me think of 
>> the functionality Apple recently (how recently I'm not sure) added to the 
>> iOS Notes app.  It allows you to selectively 'encrypt' (password protect) a 
>> note.  This functionality allows you to pass your phone to someone to let 
>> them read a note and not worry about them skipping to your note with all 
>> your 'secret info'.  Also, if someone got your phone in an unlocked state, 
>> (it could happen I guess) they couldn't trust a Mac and browse to plain text 
>> files.  
> 
> I hadn’t heard of that feature. It seems a bit odd, but I suppose people do 
> share devices.
> Does Apple explicitly refer to this as “encryption"?

Yea, they refer to it as 'Lock Note' and you click on the share icon (the 
rectangle with the arrow pointing out the top) to access it.  You provide a 
password (one for all locked notes) and you can enable Touch ID.  I don't know 
if the files are actually encrypted, but the UI behavior made me think that the 
OP was looking for something along these lines.  It provides a 'sense' of 
security.  But as has been so eloquently pointed out, if not done well it may 
just be a sense and not actually secure.

> If not, I suspect that they’re simply storing a password with the note, and 
> the GUI won’t display the note until you enter the password.
> 
>> I must say at this point I whole heartedly agree with all the warnings for 
>> implementing encryption schemes.  But is there not also a valid use case 
>> here?  Unless I'm misunderstanding things, Apple seemed to think so.
> 
> There’s some use in a scenario like this, and it could be a nice feature to 
> add to apps … if there were a convenient and trustworthy file encryption API 
> available. But there doesn’t seem to be. (I don’t know what it is about Apple 
> and crypto APIs, but there appears to be zero interest in or competence at 
> improving them. If anything, they appear to get worse over time.)
> 
> —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/archive%40mail-archive.com

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


Re: Is cloning the same as copying in APFS?

2017-06-26 Thread Sandor Szatmari

> On Jun 26, 2017, at 22:45, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Jun 26, 2017, at 19:17 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Are you talking about just a regular old copy or a copy in the sense of a 
>> time machine backup?  Are these behaviors different on APFS?
> 
> Yes and no. A regular old copy will create metadata for a new file, and point 
> back to the data blocks of the copied file. A time machine backup will create 
> a snapshot, which is effect a copy of all the metadata in the volume, with 
> the same shared pointers to the data blocks.

Yes, I felt the description of the copy on write behavior was intended to be 
universal to all copy operations not just a special operation reserved for time 
machine.  But, my even more admittedly vague understanding did not allow me to 
confidently draw a distinction be tween the two.  Thank you for tipping the 
scales.

> 
> In both cases, the functionality relies on the copy-on-write behavior, which 
> works at the data block level, not the file level.
Yes, this is very nice...
> (The latter point is worth keeping in mind, because it means that deleting 
> files in APFS may not recover all of the file’s size into free space.)
The ADC video stresses this point several times.

> 
>> On Jun 26, 2017, at 19:38 , Rick Mann <rm...@latencyzero.com> wrote:
>> 
>> But there's actually a POSIX "clone" API, and so I wonder if a copy is 
>> different from a clone.
> 
> My (admittedly vague) understanding is that all file system copy operations 
> are expected to be clones. I would imagine the difference between the APIs to 
> be that a “copy" will do a traditional duplication if the source file is 
> uncloneable (e.g. on a non-APFS volume), but the “clone” would fail.
> 
> But it would be a big hole if existing apps that copy items didn’t get the 
> cloning behavior by default.
> 
___

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: file encription/decriptoin iOS

2017-06-26 Thread Sandor Szatmari
This is an interesting thread.  The OP's original question made me think of the 
functionality Apple recently (how recently I'm not sure) added to the iOS Notes 
app.  It allows you to selectively 'encrypt' (password protect) a note.  This 
functionality allows you to pass your phone to someone to let them read a note 
and not worry about them skipping to your note with all your 'secret info'.  
Also, if someone got your phone in an unlocked state, (it could happen I guess) 
they couldn't trust a Mac and browse to plain text files.  

I must say at this point I whole heartedly agree with all the warnings for 
implementing encryption schemes.  But is there not also a valid use case here?  
Unless I'm misunderstanding things, Apple seemed to think so.

Sandor

> On Jun 26, 2017, at 13:59, Jens Alfke  wrote:
> 
> 
>> On Jun 26, 2017, at 9:50 AM, Alex Zavatone  wrote:
>> 
>> You can use the iExplore app to look in the Documents folder of any device 
>> you attach to your Mac. 
> 
> But you can only attach a device to your Mac if the device is unlocked, since 
> you have to OK the “Do you trust this computer?” alert.
> As recent court cases have shown, unlocking an iOS device against the owner’s 
> will is nearly impossible.
> 
>> Also, data protection SUCKS because it locks the files if the app goes in to 
>> the background, basically suspending any file based background operations 
>> like sql db updates. 
> 
> It does this by default, but you can alter those settings if you need 
> background access to certain files, basically trading some security for 
> greater access.
> 
>> Thanks to the help of Chris Thorman, I was able to update an AES256 hmac 
>> method to work with UTF-8 char sets.  We use this for data security over 
>> http.
> 
> It’s much easier to just enable SSL/TLS on the HTTP server. (Though I realize 
> there are cases where you don’t have control over the server, or 
> circumstances prevent deploying HTTPS.)
> 
>> Now, it might be overkill or just bad design, but we use a CoreData db with 
>> transformable property and encrypt the data stored. 
> 
> How do you store the encryption key? That’s often the downfall; even if you 
> put it in the Keychain, it can be accessed by an attacker if your app’s files 
> are accessible (unless you add TouchID authentication to it.)
> 
> (Also, I hope you’re using a different IV for each record you encrypt. Sorry 
> to be a broken record about this, but it’s important.)
> 
> —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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Is cloning the same as copying in APFS?

2017-06-26 Thread Sandor Szatmari
Are you talking about just a regular old copy or a copy in the sense of a time 
machine backup?  Are these behaviors different on APFS?

The ADC video Quincey referred to a couple of weeks ago talked about references 
to files being created (lazy copies).  Only when the blocks associated with the 
newest reference are altered would any actual copying of actual data be done.

Is this the behavior your referring to?

Sandor

> On Jun 26, 2017, at 21:34, Rick Mann  wrote:
> 
> If I use NSFileManager to make a copy on an APFS volume, will it make a clone 
> underneath?
> 
> Is there a Cocoa API for cloning?
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: Overriding the release mehod

2017-01-26 Thread Sandor Szatmari
I would take that one step further and say that because I expect that type of 
deep introspection I enjoy when find the answers to questions I intend to post 
before posting them, while preparing an email.  As such, I find reading the 
discourse of this list interesting and valuable.

Sandor

> On Jan 25, 2017, at 18:49, Jonathan Hull  wrote:
> 
> One of my favorite things about this list is that the standard response to a 
> question is to ask about the underlying motivation.  It shows that they are 
> prepared to think deeply about your problem and don’t want to just give you a 
> cookie cutter answer.  One of the main signs of an intelligent person in my 
> mind :-)
> 
> Thanks,
> Jon
> 
>> On Jan 25, 2017, at 3:38 PM, Greg Parker  wrote:
>> 
>> What Are You Trying To Do™ is in fact precisely the correct response to your 
>> question. Some overrides of -release need to call [super release]. Others do 
>> not. It depends on … what they are trying to do.
>> 
>> Overriding release to unregister an observer is almost certainly a bad idea, 
>> but yes, such an override ought to call [super release] if the object is 
>> expected to be retained and released and deallocated normally. 
>> 
>> 
>> -- 
>> Greg Parker gpar...@apple.com  Runtime 
>> Wrangler
>> 
>> 
>>> On Jan 25, 2017, at 8:23 AM, Dave  wrote:
>>> 
>>> I hate it when people as that question! There are some memory leaks in a 
>>> 3rd party package. It overrides release to unregister an observer but 
>>> doesn’t call super. If I call super the leaks go away and all is well. I 
>>> just want to know where is it documented really, I can’t find it searching 
>>> the docs.
>>> 
>>> Cheers
>>> Dave
>>> 
 On 25 Jan 2017, at 15:55, Mike Abdullah  wrote:
 
 You’re inevitably going to get asked this:
 Why on earth are you overriding release? It’s an incredibly niche thing to 
 do, and the answer probably depends a lot on why you’re overriding it.
 
> On 25 Jan 2017, at 16:52, Dave  wrote:
> 
> Hi,
> 
> Does [suoer release] need to be called if you override this method? I’m 
> 99.9% sure it does, but I can’t find it anywhere it actually says it 
> in black and white.
> 
> All the Best
> Dave
>> 
>> ___
>> 
>> 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/jhull%40gbis.com
>> 
>> This email sent to jh...@gbis.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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Seeing nil passed to isEqual:, despite non-null declaration

2017-01-13 Thread Sandor Szatmari
I was thinking, and I'm guessing there were no warnings and errors in Xcode on 
this line of code, that a clean compile would indicate that the header did not 
match the documentation.  Does this make sense?

Sandor

> On Jan 13, 2017, at 12:53, Jens Alfke  wrote:
> 
> 
>> On Jan 13, 2017, at 9:46 AM, Sean McBride  wrote:
>> 
>> Anyone ever seen nil passed to isEqual:?  Is the SDK declaration maybe wrong?
> 
> Check the class documentation, not just the header. The parameter is declared 
> as:
>anObjectThe object to be compared to the receiver. May be nil, in 
> which case this method returns NO.
> 
> So yes, the parameter should be declared as `nullable`.
> 
> —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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Opposite of windowDidLoad

2017-01-12 Thread Sandor Szatmari
If the window has the same lifespan as the controller, why not dealloc?  
Otherwise, wherever your closing your window.

Sandor

> On Jan 12, 2017, at 06:46, Daryle Walker  wrote:
> 
> I was thinking of adding a Cocoa Binding during my window-controller's 
> did-load method. But where would the unbinding go? I see waiting until deinit 
> or implementing NSWindowDelegate and using windowWillClose.
> 
> Is there a similar access point for view-controllers?
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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


Re: 12 hr vs 24 hr time display

2017-01-04 Thread Sandor Szatmari
Alex,

This is interesting, and thanks for digging it up.

Using this plist it appears that I could use [[NSUserDefaults 
standardUserDefaults]  addSuiteNamed:@"com.apple.menuextra.clock"] and access 
this data with the key 'DateFormat'.  I'm not sure I want to do this.  I expect 
there is a degree of fragility.  Apple could change the domain or the key.  
But, it's good to be able to consider it.  With this I could find out how the 
user has there clock configured.

Although, here I'm not sure I should look for 'a'.  Previously I was relying on 
the template functionality's response to the special token of 'j'. As your 
examples illustrate, the absence of 'a' could just indicate the preference of 
no 'period' in the format string.  But the uppercase 'H' is a strong enough 
indicator.

Thanks again for your time and thoughts.

Sandor

> On Jan 4, 2017, at 00:54, Alex Zavatone  wrote:
> 
> OK.  All that NSLocale stuff seemed like "The right way to do it™" but…
> 
> Let's see if this gets you what you want.
> 
> Read this file:
> 
> ~/Library/Preferences/
> com.apple.menuextra.clock.plist
> 
> And you'll see…
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
> 
> EEE h:mm 
> 
> 
> 
> Or
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
> 
> EEE h:mm a
> 
> 
> Or
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd;>
> 
> EEE H:mm
> 
> 
> The differences here are:
> 
> EEE h:mm – 12 hour clock, no AM/PM shown
> EEE h:mm a – 12 hour clock, AM/PM shown
> EEE H:mm – 24 hour clock
> 
> Hope that helps.
> 
> - Z
___

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: 12 hr vs 24 hr time display

2017-01-04 Thread Sandor Szatmari
Jeremy,

> On Jan 4, 2017, at 08:56, Jeremy Pereira <jeremy.j.pere...@icloud.com> wrote:
> 
> 
>> On 3 Jan 2017, at 16:34, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Jeremy,
>> 
>>> On Jan 3, 2017, at 10:30, Jeremy Pereira 
>>> <jeremy.pere...@aptosolutions.co.uk> wrote:
>>> 
>>> 
>>>> 
>>> 
>>> It seems obvious to me that method 1 only refers to the clock display in 
>>> the menu bar and nothing else. It’s a sub setting of 
>>> “Show date and time in the menu bar”.
>>> 
>>> If you honour whatever preference is set by method 2 as your code fragment 
>>> below does, you’ll be fine.
>>> 
>> I feel like fewer people use/find method 2, simply stopping at method 1.  
>> This may be a gross assumption on my part.  Under my assumption they would 
>> simply think my app doesn't display 24 hr time or respect the system 
>> setting.  Am I being to sensitive here?
> 
> Yes, because they would also be thinking that all the other apps don’t 
> respect 24 hour format including Finder windows.

Good point... Thanks!

Sandor
___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Alex,

> On Jan 3, 2017, at 19:51, Alex Zavatone <z...@mac.com> wrote:
> 
> 
>> On Jan 3, 2017, at 3:02 PM, Sandor Szatmari wrote:
>> 
>> Gary,
>> 
>>> On Jan 3, 2017, at 14:52, Gary L. Wade <garyw...@desisoftsystems.com> wrote:
>>> 
>>> Is there a problem with using +[NSDateFormatter 
>>> localizedStringFromDate:dateStyle:timeStyle:]? Depending on your needs, you 
>>> might also consider +[NSCalendar autoupdatingCurrentCalendar].
>> 
>> I am looking for detecting whether or not the system defaults to 12 or 24 hr 
>> time.  The obj-c method I'm already 'parsing', -dateFormatFromTemplate:::, 
>> returns a template string with well defined formatting tokens that are easy 
>> to detect.  Plus they directly reflect the user's Locale & Region settings.
> 
> I'd expect that would be a function of the language and the locale, possibly 
> just the locale.  Do you care what it defaults to or what it's currently set 
> to?

That's correct and I only care so far as I can determine it as being either 12 
or 24.  

The relevant methods are, -dateFormatFromTemplate::: returns a format string 
which -localizedStringFromDate:dateStyle:timeStyle: consumes to produces a 
human readable Date string.  I am not doing the second step described here.  
Producing he actual string the view is separate from this state stored in my 
model.

The relevant bits are: -dateFormatFromTemplate::: with a template of 'j' 
returns the default format string for the Locale passed as the Locale argument. 
 I am passing [NSLocale currentLocale].  

It is my understanding that any Locale which supports the 12 hr time format 
must represent the AM/PM as 'a' in the format string provided to 
-localizedStringFromDate:dateStyle:timeStyle:.  So therefore the presence of 
'a' indicates that the Locale is configured for 12 hr time.  Otherwise, it's 24 
hr time.  What I am relying on is the behavior of -dateFormatFromTemplate::: 
when passed the 'j' template.  This behavior is documented here 
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns.
  It specifically mentions using 'j' to determine the presence AM/PM or not.  
i.e. 12 or 24 hr time.

Might some Locales only support 12 or 24?  Maybe, maybe not.  But if I decide 
to only rely on the setting from Locale & Region and my interpretations are 
good this should not matter.  The user will never see 12 or 24 for locales that 
do not support them.
The specific section is 
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Day_Period_Rules.

Thanks,
Sandor

> 
> - Z
> 
___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Gary,

> On Jan 3, 2017, at 18:40, Gary L. Wade <garyw...@desisoftsystems.com> wrote:
> 
> What I’m getting at is how relevant is it to your app that you know if and 
> where the time-of-day indicators exist in addition to the 24-hour setting.  
> Answering those questions should be what determines your next steps.  
> As mentioned, the alarm clock has a long history on the Mac whereas the 
> Unicode underpinnings for these locale settings are "relatively recent.”  If 
> all you care about is putting out a time, try using localizedStringFromDate:….
All I ever display is hours and minutes for the purposes of this app.  This is 
the simple part.  It was deciding whether or not to display 24 or 12 hour time 
which was at question.

> If you absolutely have to have full control over the format string, unless 
> the user wants a change, always use the system settings, and model your 
> override UI after that provided in the system preferences.
Yea, I thought about duplicating the system's UI, but I find it hard to decide 
to emulate something I think could be better.  But, it might be the most 
consistent experience for the user.

>  If you’re wanting even greater details, try looking for IBM’s ICU test pages;
Great suggestion, thanks!

Sandor

> I’m sure they’re still around somewhere, and they allow you to run through 
> all locales in existence, even some that Apple may not currently support.
> --
> Gary L. Wade
> http://www.garywade.com/
> 
>> On Jan 3, 2017, at 1:02 PM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Gary,
>> 
>> On Jan 3, 2017, at 14:52, Gary L. Wade <garyw...@desisoftsystems.com> wrote:
>> 
>>> Is there a problem with using +[NSDateFormatter 
>>> localizedStringFromDate:dateStyle:timeStyle:]? Depending on your needs, you 
>>> might also consider +[NSCalendar autoupdatingCurrentCalendar].
>> 
>> I am looking for detecting whether or not the system defaults to 12 or 24 hr 
>> time.  The obj-c method I'm already 'parsing', -dateFormatFromTemplate:::, 
>> returns a template string with well defined formatting tokens that are easy 
>> to detect.  Plus they directly reflect the user's Locale & Region settings.
>>> 
>>> 
>>> A user typically “sets” their region settings when they set up their Mac, 
>>> and the choice of 12/24 hour display defaults to what the selected region 
>>> uses.  Few people change things after that, although I am, preferring a 
>>> four-digit year vs two-digit for the short date format.
>> 
>> Great point!  This is exactly why I wanted to follow a user's Locale & Date 
>> preference.  The only issue I had was that the preference's place of 
>> definition appeared vague to me.  It is tenuously tied to the Date & Time 
>> preference for the menu bar clock.  Your point is good because user's decide 
>> this once, early on.  Why should they have to specify it for every 
>> application.  Maybe providing an option to override the default behavior is 
>> the way to go.  Maybe a three state toggle or matrix.  
>> 
>> A. Follow Locale & Region
>> B. Override with 12 hr
>> C. Override with 24 hr
>> 
>> There is some redundancy in there depending on the Locale & Region setting 
>> but, at least to me it's self explanatory.  Is that too confusing?
>> 
>> Thanks,
>> Sandor
>> 
>>> --
>>> Gary L. Wade
>>> http://www.garywade.com/
>>> 
>>>> On Jan 3, 2017, at 8:34 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
>>>> wrote:
>>>> 
>>>> Jeremy,
>>>> 
>>>>>> On Jan 3, 2017, at 10:30, Jeremy Pereira 
>>>>>> <jeremy.pere...@aptosolutions.co.uk> wrote:
>>>>>> 
>>>>>> 
>>>>>> On 3 Jan 2017, at 06:16, Sandor Szatmari <admin.szatmari@gmail.com> 
>>>>>> wrote:
>>>>>> 
>>>>>> I am working on a small application where the primary function is to 
>>>>>> display the time to the user.  My hope was to honor the user's 
>>>>>> preference setting.  I am either missing something or honoring the 
>>>>>> user's preference is harder than expected.
>>>>>> 
>>>>>> So, there are two places to set 24 hr time display.
>>>>>> 
>>>>>> 1. Date & Time preference panel
>>>>>> 2. Language & Region preference panel 
>>>>>> 
>>>>>> The cocoa frameworks react differently depending on where you set

Re: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Sean,

> On Jan 3, 2017, at 15:32, Sean McBride <s...@rogue-research.com> wrote:
> 
> On Tue, 3 Jan 2017 11:26:48 -0500, Sandor Szatmari said:
> 
>> What I was asking for clarity on is the fact that there is no way to
>> detect that the user prefers 24 hr time display if they only choose
>> method 1, the Date & Time checkbox.  Should I allow my users to set 12
>> hr time but override it to 24 hr time if the Language & Region checkbox
>> is checked?  This doesn't feel right.  I feel like Apple left room for
>> ambiguity in their design here.
> 
> If I were you I would just forget about the setting for the menu bar clock.  
> I agree it's weird that it even exists (file a bug) but it's clearly meant 
> only for the menu bar clock.  Just use NSDateFormatter and add some UI in 
> your app showing the user the proper place to set her preferred date/time 
> format options.

I'm coming around to something like this.  Thanks!  

Sandor
> 
> Cheers,
> 
> -- 
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com 
> Mac Software Developer  Montréal, Québec, Canada
> 
> 

___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Gary,

> On Jan 3, 2017, at 14:52, Gary L. Wade <garyw...@desisoftsystems.com> wrote:
> 
> Is there a problem with using +[NSDateFormatter 
> localizedStringFromDate:dateStyle:timeStyle:]?  Depending on your needs, you 
> might also consider +[NSCalendar autoupdatingCurrentCalendar].

I am looking for detecting whether or not the system defaults to 12 or 24 hr 
time.  The obj-c method I'm already 'parsing', -dateFormatFromTemplate:::, 
returns a template string with well defined formatting tokens that are easy to 
detect.  Plus they directly reflect the user's Locale & Region settings.
> 
> 
> A user typically “sets” their region settings when they set up their Mac, and 
> the choice of 12/24 hour display defaults to what the selected region uses.  
> Few people change things after that, although I am, preferring a four-digit 
> year vs two-digit for the short date format.

Great point!  This is exactly why I wanted to follow a user's Locale & Date 
preference.  The only issue I had was that the preference's place of definition 
appeared vague to me.  It is tenuously tied to the Date & Time preference for 
the menu bar clock.  Your point is good because user's decide this once, early 
on.  Why should they have to specify it for every application.  Maybe providing 
an option to override the default behavior is the way to go.  Maybe a three 
state toggle or matrix.  

A. Follow Locale & Region
B. Override with 12 hr
C. Override with 24 hr

There is some redundancy in there depending on the Locale & Region setting but, 
at least to me it's self explanatory.  Is that too confusing?

Thanks,
Sandor

> --
> Gary L. Wade
> http://www.garywade.com/
> 
>> On Jan 3, 2017, at 8:34 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Jeremy,
>> 
>>>> On Jan 3, 2017, at 10:30, Jeremy Pereira 
>>>> <jeremy.pere...@aptosolutions.co.uk> wrote:
>>>> 
>>>> 
>>>> On 3 Jan 2017, at 06:16, Sandor Szatmari <admin.szatmari@gmail.com> 
>>>> wrote:
>>>> 
>>>> I am working on a small application where the primary function is to 
>>>> display the time to the user.  My hope was to honor the user's preference 
>>>> setting.  I am either missing something or honoring the user's preference 
>>>> is harder than expected.
>>>> 
>>>> So, there are two places to set 24 hr time display.
>>>> 
>>>> 1. Date & Time preference panel
>>>> 2. Language & Region preference panel 
>>>> 
>>>> The cocoa frameworks react differently depending on where you set this.
>>>> 
>>>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>>>> appears this is cosmetic in that it only affects the display of the clock 
>>>> in the NSStatusBar.
>>>> 
>>>> If set by method 2, cocoa frameworks reflect this and the Date & Time 
>>>> setting is disabled noting that the setting has been overridden.
>>>> 
>>>> So if a user uses method 1, potentially unaware of method 2, how should 
>>>> one go about determining the user's intentions.
>>> 
>>> It seems obvious to me that method 1 only refers to the clock display in 
>>> the menu bar and nothing else. It’s a sub setting of 
>>> “Show date and time in the menu bar”.
>>> 
>>> If you honour whatever preference is set by method 2 as your code fragment 
>>> below does, you’ll be fine.
>>> 
>> I feel like fewer people use/find method 2, simply stopping at method 1.  
>> This may be a gross assumption on my part.  Under my assumption they would 
>> simply think my app doesn't display 24 hr time or respect the system 
>> setting.  Am I being to sensitive here?
>> 
>> Sandor
>>> 
>>>> 
>>>> There are deprecated methods using: (didn't try, it's deprecated)
>>>>  NSUserDefaults with the key NSShortTimeDateFormatString
>>>> 
>>>> There are supported methods using: (works with method 2)
>>>>  NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>>>> locale:[NSLocale currentLocale]];
>>>>  BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
>>>> 
>>>> Can anyone provide any clarity here?
>>>> 
>>>> Sandor
>>>> ___
>>>> 
>>>> 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/adc%40jeremyp.net
>>>> 
>>>> This email sent to a...@jeremyp.net
>>> 
>>> --
>>> Jeremy Pereira
>>> jeremy.pere...@aptosolutions.co.uk
>>> 07884 265457
> 
___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Quincey,

> On Jan 3, 2017, at 14:46, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Jan 3, 2017, at 05:00 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Are you suggesting case sensitivity is an issue here?  If so, I don't think 
>> so.  The template returned from this method uses 'a' as a place holder for 
>> AM/PM.  e.g. It might return the string 'h a' as it does by default for the 
>> English/US locale on my system, and a is always lower case.  This is 
>> described here 
>> http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
>>  See the 'period' field in the Date Field Symbol Table and section 8.2 for 
>> my justification.
> 
> I was, but (sorry) that was because I didn’t read your code carefully enough.
> 
>> Yea, I was considering just making it an app local preference but that 
>> strikes me as crude.  Ideally speaking, at best an appropriate preference 
>> for my app could be 'Override System 24 hr time preference' or something 
>> akin.
> 
> Why can’t be the app preference simply be “Show 24 hr time” and default to 
> the locale setting? Which is to say, the same thing you said but without the 
> semi-pejorative description.
This discussion has proven very helpful.  Putting it that way makes me feel 
like I can satisfy my feeling of ambiguity by adjusting the wording in my 
preference panel.  I feel the wording of something like 'Show 24 hr time 
according to Locale & Region Setting' works.  Too wordy, I know, but making the 
UI self explanatory/teaching is important to me.
> 
> TBH, I think the menu bar clock has an overriding setting only for historical 
> reasons. However, it doesn’t seem completely unlikely that a user might want 
> the always-visible clock to be different from formatted times. It may be that 
> the locale (or bureaucratic policy) might mandate that one format is used for 
> dates/times generally, but a specific user might be more comfortable telling 
> *time of day* using the opposite convention.
Yea, I vacillated here for a while.  It was the unidirectionally connectedness 
of these features that to me implied these features were coupled and yet they 
weren't at the same time.  Apple allows this distinction when the Locale & 
Region 24 hr checkbox is unchecked (Locale says 12hr/clock can be 12 or 24hr), 
but disables the Date & Time checkbox when the Locale & Region checkbox IS 
checked (Locale and clock are both 24 hr).
> 
> Similarly and analogously, a user might have reasons for setting the Mac to 
> GMT generally, but still want to display local time in the menu bar.
> 
I agree with your examples but Apple has carved out a space where they disallow 
a distinction.  I can see why they would be forced to be in sync.  I can see 
why they would be allowed to be independent.  I cannot reason why it is 
implemented as it is.
> 

Thanks,
Sandor
___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Alex,

> On Jan 3, 2017, at 13:47, Alex Zavatone <z...@mac.com> wrote:
> 
> iOS or Mac?
> 
> In any case, this will help you out to no end.
> 
> http://NSDateformatter.com/

Thanks, I'll check this out.
> 
> And note that the case of the letters you use in your formatter matter.

I don't think I said case doesn't matter.  It certainly does... e.g. A vs. a, H 
vs. h, Y vs. y, ...  have significance.  As far as I'm aware, and according to 
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
 there is only one specifier for AM/PM, and that is lowercase 'a', and it is 
germane only to 12 hr time format strings.  'A' specifies milliseconds in day.  
The only discussion of case was when I explained why I didn't need to, or 
rather shouldn't, consider uppercase 'AM'.  Those tokens have independent 
significance in a format string.  To clarify for future readers of this thread, 
I was not implying case doesn't matter.  Indeed, I was saying case does matter 
and looking for lowercase 'a' was appropriate.  Thanks for pointing that out.

Sandor

> 
> GL.
> - Alex Zavatone
> 
> 
>> On Jan 3, 2017, at 12:16 AM, Sandor Szatmari wrote:
>> 
>> I am working on a small application where the primary function is to display 
>> the time to the user.  My hope was to honor the user's preference setting.  
>> I am either missing something or honoring the user's preference is harder 
>> than expected.
>> 
>> So, there are two places to set 24 hr time display.
>> 
>> 1. Date & Time preference panel
>> 2. Language & Region preference panel 
>> 
>> The cocoa frameworks react differently depending on where you set this.
>> 
>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>> appears this is cosmetic in that it only affects the display of the clock in 
>> the NSStatusBar.
>> 
>> If set by method 2, cocoa frameworks reflect this and the Date & Time 
>> setting is disabled noting that the setting has been overridden.
>> 
>> So if a user uses method 1, potentially unaware of method 2, how should one 
>> go about determining the user's intentions.
>> 
>> There are deprecated methods using: (didn't try, it's deprecated)
>>   NSUserDefaults with the key NSShortTimeDateFormatString
>> 
>> There are supported methods using: (works with method 2)
>>   NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>> locale:[NSLocale currentLocale]];
>>   BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
>> 
>> Can anyone provide any clarity here?
>> 
>> Sandor
>> ___
>> 
>> 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/archive%40mail-archive.com

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


Re: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Steve,

> On Jan 3, 2017, at 12:28, Steve Christensen <puns...@mac.com> wrote:
> 
>> On Jan 3, 2017, at 8:26 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Steve,
>> 
>>> On Jan 3, 2017, at 10:17, Steve Christensen <puns...@mac.com> wrote:
>>> 
>>> In the Date & Time preference panel, I assume that you're referring to the 
>>> option on the Clock tab. If so, those settings refer only to the menubar 
>>> clock display.
>> I just think it's weird that there are two checkboxes.  It seems odd to me 
>> that one would want a 24 hr clock in the menu bar but not anywhere else.
> 
> The menubar clock settings also have options for displaying the time with or 
> without seconds, showing AM/PM, showing the day of the week, and showing the 
> date. These options all affect the final representation in the menubar, 
> independent of the locale settings, but you're focusing on just one of these.
Yes, I agree.
> 
> I have a little bit of experience with the menubar clock in the pre-OS X 
> world so I happen to know that those particular options were present as early 
> as 1992, so people have been living with the arrangement for a long time.
> 
>>> If you notice in that same preference panel, on the Date & Time tab, there 
>>> is a message at the bottom that says, "To set date and time formats, use 
>>> the Language & Region preferences." Clicking the button takes you to that 
>>> other panel, and there you will find a checkbox that lets you select 
>>> 24-hour time.
>> Yes, this is method 2 I referred to.  If you check the Language & Region 
>> checkbox it overrides the Date & Time checkbox, enabling 24 hr time display 
>> in the menu bar clock and disabling the Date & Time checkbox.  So clearly 
>> someone at Apple sees there is at least a one direction connection between 
>> these two checkboxes.
> 
> That's merely an implementation detail related to a private system feature. 
> It's no different than if you were to put such an option in your app.
I think it was the fact that Apple made a one direction connection allowing the 
clock's preference to be overridden is what made this unclear for me.
> 
>>> The Language & Region settings are what specify the locale that is used for 
>>> formatting date and time values (among other things), which is why you see 
>>> those changes reflected in the NSDateFormatter methods.
>> Yes, this discrepancy (IMHO) is what I was asking about.  I don't see why 
>> the option for the clock display would be separated from this option.
>> 
>> What I was asking for clarity on is the fact that there is no way to detect 
>> that the user prefers 24 hr time display if they only choose method 1, the 
>> Date & Time checkbox.  Should I allow my users to set 12 hr time but 
>> override it to 24 hr time if the Language & Region checkbox is checked?  
>> This doesn't feel right.  I feel like Apple left room for ambiguity in their 
>> design here.
> 
> The locale settings, in the Language & Region preference panel, specifies the 
> user's current preferences in terms of general time formatting. The clock 
> settings specify the user's current preferences for the menubar clock. I 
> don't see the ambiguity.
I guess Apple thought that setting the Language & Region 24 hr time setting was 
strong enough for them to disallow the menu bar clock from being displayed in 
12 hr format when it, the Language & Region, preference is set.

I guess part of me felt like the the clock should either be totally in sync 
with the Language & Region setting, or totally independent.  Understanding this 
better, I will have to just pick one implementation.

Thanks for everyone's opinions.

> 
> 
>>>> On Jan 2, 2017, at 10:16 PM, Sandor Szatmari 
>>>> <admin.szatmari@gmail.com> wrote:
>>>> 
>>>> I am working on a small application where the primary function is to 
>>>> display the time to the user.  My hope was to honor the user's preference 
>>>> setting.  I am either missing something or honoring the user's preference 
>>>> is harder than expected.
>>>> 
>>>> So, there are two places to set 24 hr time display.
>>>> 
>>>> 1. Date & Time preference panel
>>>> 2. Language & Region preference panel 
>>>> 
>>>> The cocoa frameworks react differently depending on where you set this.
>>>> 
>>>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>>>> appears this is cosmetic 

Re: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Jeremy,

> On Jan 3, 2017, at 10:30, Jeremy Pereira <jeremy.pere...@aptosolutions.co.uk> 
> wrote:
> 
> 
>> On 3 Jan 2017, at 06:16, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> I am working on a small application where the primary function is to display 
>> the time to the user.  My hope was to honor the user's preference setting.  
>> I am either missing something or honoring the user's preference is harder 
>> than expected.
>> 
>> So, there are two places to set 24 hr time display.
>> 
>> 1. Date & Time preference panel
>> 2. Language & Region preference panel 
>> 
>> The cocoa frameworks react differently depending on where you set this.
>> 
>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>> appears this is cosmetic in that it only affects the display of the clock in 
>> the NSStatusBar.
>> 
>> If set by method 2, cocoa frameworks reflect this and the Date & Time 
>> setting is disabled noting that the setting has been overridden.
>> 
>> So if a user uses method 1, potentially unaware of method 2, how should one 
>> go about determining the user's intentions.
> 
> It seems obvious to me that method 1 only refers to the clock display in the 
> menu bar and nothing else. It’s a sub setting of 
> “Show date and time in the menu bar”.
> 
> If you honour whatever preference is set by method 2 as your code fragment 
> below does, you’ll be fine.
> 
I feel like fewer people use/find method 2, simply stopping at method 1.  This 
may be a gross assumption on my part.  Under my assumption they would simply 
think my app doesn't display 24 hr time or respect the system setting.  Am I 
being to sensitive here?

Sandor
> 
>> 
>> There are deprecated methods using: (didn't try, it's deprecated)
>>   NSUserDefaults with the key NSShortTimeDateFormatString
>> 
>> There are supported methods using: (works with method 2)
>>   NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>> locale:[NSLocale currentLocale]];
>>   BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
>> 
>> Can anyone provide any clarity here?
>> 
>> Sandor
>> ___
>> 
>> 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/adc%40jeremyp.net
>> 
>> This email sent to a...@jeremyp.net
> 
> --
> Jeremy Pereira
> jeremy.pere...@aptosolutions.co.uk
> 07884 265457
> 
> 
> 
> 

___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Steve,

> On Jan 3, 2017, at 10:17, Steve Christensen <puns...@mac.com> wrote:
> 
> In the Date & Time preference panel, I assume that you're referring to the 
> option on the Clock tab. If so, those settings refer only to the menubar 
> clock display.
I just think it's weird that there are two checkboxes.  It seems odd to me that 
one would want a 24 hr clock in the menu bar but not anywhere else.
> 
> If you notice in that same preference panel, on the Date & Time tab, there is 
> a message at the bottom that says, "To set date and time formats, use the 
> Language & Region preferences." Clicking the button takes you to that other 
> panel, and there you will find a checkbox that lets you select 24-hour time.
Yes, this is method 2 I referred to.  If you check the Language & Region 
checkbox it overrides the Date & Time checkbox, enabling 24 hr time display in 
the menu bar clock and disabling the Date & Time checkbox.  So clearly someone 
at Apple sees there is at least a one direction connection between these two 
checkboxes.
> 
> The Language & Region settings are what specify the locale that is used for 
> formatting date and time values (among other things), which is why you see 
> those changes reflected in the NSDateFormatter methods.
Yes, this discrepancy (IMHO) is what I was asking about.  I don't see why the 
option for the clock display would be separated from this option.

What I was asking for clarity on is the fact that there is no way to detect 
that the user prefers 24 hr time display if they only choose method 1, the Date 
& Time checkbox.  Should I allow my users to set 12 hr time but override it to 
24 hr time if the Language & Region checkbox is checked?  This doesn't feel 
right.  I feel like Apple left room for ambiguity in their design here.
> 
> 
>> On Jan 2, 2017, at 10:16 PM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> I am working on a small application where the primary function is to display 
>> the time to the user.  My hope was to honor the user's preference setting.  
>> I am either missing something or honoring the user's preference is harder 
>> than expected.
>> 
>> So, there are two places to set 24 hr time display.
>> 
>> 1. Date & Time preference panel
>> 2. Language & Region preference panel 
>> 
>> The cocoa frameworks react differently depending on where you set this.
>> 
>> If set by method 1, cocoa frameworks seem unaware of this setting and it 
>> appears this is cosmetic in that it only affects the display of the clock in 
>> the NSStatusBar.
>> 
>> If set by method 2, cocoa frameworks reflect this and the Date & Time 
>> setting is disabled noting that the setting has been overridden.
>> 
>> So if a user uses method 1, potentially unaware of method 2, how should one 
>> go about determining the user's intentions.
>> 
>> There are deprecated methods using: (didn't try, it's deprecated)
>>   NSUserDefaults with the key NSShortTimeDateFormatString
>> 
>> There are supported methods using: (works with method 2)
>>   NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>> locale:[NSLocale currentLocale]];
>>   BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
>> 
>> Can anyone provide any clarity here?
>> 
>> Sandor
> 

___

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: 12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
Quincy,



Sandor
> On Jan 3, 2017, at 04:35, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Jan 2, 2017, at 22:16 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> There are supported methods using: (works with method 2)
>>NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
>> locale:[NSLocale currentLocale]];
>>BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);
> 
> Well of course this won’t work in every locale, not even all the 
> English-speaking ones, since (IIRC) it’s “AM” in some of them, but I assume 
> you’ve breezed right past that small point. :)

Are you suggesting case sensitivity is an issue here?  If so, I don't think so. 
 The template returned from this method uses 'a' as a place holder for AM/PM.  
e.g. It might return the string 'h a' as it does by default for the English/US 
locale on my system, and a is always lower case.  This is described here 
http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
 See the 'period' field in the Date Field Symbol Table and section 8.2 for my 
justification.

> 
> It seems to me you have two choices. One is to honor the setting for time 
> *text* and to use the date formatter result unmodified (which means you might 
> get more characters than just the 3 or 4 or 5 that represent the time with a 
> possible separator). Or, if your app really is more like a clock, then I’d 
> make the 12/24 hr format a setting within the app. As you’ve seen from the 
> menu bar clock, there does seem to be a possible distinction between clock 
> time format and annotation time. Since you can’t access the menu bar format 
> (no public API at least), a one-time app setting seems reasonable.

Yea, I was considering just making it an app local preference but that strikes 
me as crude.  Ideally speaking, at best an appropriate preference for my app 
could be 'Override System 24 hr time preference' or something akin.

But, I might have to settle for that...
> 
___

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

12 hr vs 24 hr time display

2017-01-03 Thread Sandor Szatmari
I am working on a small application where the primary function is to display 
the time to the user.  My hope was to honor the user's preference setting.  I 
am either missing something or honoring the user's preference is harder than 
expected.

So, there are two places to set 24 hr time display.

1. Date & Time preference panel
2. Language & Region preference panel 

The cocoa frameworks react differently depending on where you set this.

If set by method 1, cocoa frameworks seem unaware of this setting and it 
appears this is cosmetic in that it only affects the display of the clock in 
the NSStatusBar.

If set by method 2, cocoa frameworks reflect this and the Date & Time setting 
is disabled noting that the setting has been overridden.

So if a user uses method 1, potentially unaware of method 2, how should one go 
about determining the user's intentions.

There are deprecated methods using: (didn't try, it's deprecated)
NSUserDefaults with the key NSShortTimeDateFormatString

There are supported methods using: (works with method 2)
NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
locale:[NSLocale currentLocale]];
BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);

Can anyone provide any clarity here?

Sandor
___

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: Users default alert sound

2016-12-14 Thread Sandor Szatmari
Bonus!  Thanks for sharing!

Sandor

> On Dec 14, 2016, at 17:03, Britt Durbrow 
> <bdurb...@rattlesnakehillsoftworks.com> wrote:
> 
> Also, not everyone *has* a sound that plays… if the volume is turned all the 
> way down, or if they have a hearing issue, for example, they will often have 
> the screen flash turned on; calling NSBeep() triggers this correctly.
> 
> 
> 
>> On Dec 14, 2016, at 10:51 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> I didn't know that automatically played the configured sound.  That's great 
>> thanks!  I knew I was missing something straightforward.
>> 
>> Sandor
>> 
>>>> On Dec 14, 2016, at 12:58, Quincey Morris 
>>>> <quinceymor...@rivergatesoftware.com> wrote:
>>>> 
>>>> On Dec 14, 2016, at 09:45 , Sandor Szatmari <admin.szatmari@gmail.com> 
>>>> wrote:
>>>> 
>>>> I am currently using [NSSound soundNamed:] to play any arbitrary sound.  
>>>> But I want to play the one configured in System Preferences.
>>> 
>>> You can use the NSBeep () global function to play the configured alert 
>>> sound. I don’t know if there’s an API to get its file name — it’s not 
>>> obvious that it is even a separate file, always.
>>> 
>> ___
>> 
>> 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/bdurbrow%40rattlesnakehillsoftworks.com
>> 
>> This email sent to bdurb...@rattlesnakehillsoftworks.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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Users default alert sound

2016-12-14 Thread Sandor Szatmari
I didn't know that automatically played the configured sound.  That's great 
thanks!  I knew I was missing something straightforward.

Sandor

> On Dec 14, 2016, at 12:58, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Dec 14, 2016, at 09:45 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> I am currently using [NSSound soundNamed:] to play any arbitrary sound.  But 
>> I want to play the one configured in System Preferences.
> 
> You can use the NSBeep () global function to play the configured alert sound. 
> I don’t know if there’s an API to get its file name — it’s not obvious that 
> it is even a separate file, always.
> 
___

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

Users default alert sound

2016-12-14 Thread Sandor Szatmari
How do you determine the name of the sound as configured in 'System 
Preferences' > Sound > 'Sound Effects' > 'Select an alert sound:'?

What I'm trying to do:  I want to play the alert sound under certain 
circumstances.

I am currently using [NSSound soundNamed:] to play any arbitrary sound.  But I 
want to play the one configured in System Preferences.

Thanks,
Sandor
___

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: Stupid objective-c question

2016-09-23 Thread Sandor Szatmari
Thanks to both of you for clarifying this and for a nice solution.

Basically then, I must not use address pointed to, but instead, the address of 
the pointer itself.

I liked the readability of using a string, but I think there is too much room 
for misinterpretation, conflating the contents of the string with the 
uniqueness requirement.

Regards,
Sandor Szatmari

> On Sep 23, 2016, at 05:04, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Sep 23, 2016, at 01:36 , Alastair Houghton <alast...@alastairs-place.net> 
>> wrote:
>> 
>> Note that you can use *any* type for your variable; in some ways, it might 
>> make sense to use a non-pointer type, just to make clear that it’s the 
>> address that matters, e.g.
>> 
>> static const int kMyContext = 0xabadf00d;
>> 
>> Otherwise some smart-ass might go and delete the “&” operators from your 
>> code, and that makes it vulnerable to problems.
> 
> As previously mentioned, the safest way to do this is:
> 
>> static void* kMyContext = 
> 
> 
> That makes the “&” optional (at comparison time), and it should even avoid 
> the coalescing problem if it’s declared const.
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Stupid objective-c question

2016-09-22 Thread Sandor Szatmari
So there was lots of discussion and plenty of 'don't do anything that equates 
to this' --> @"myString" == @"myString", and I agree.  

I wanted to get some opinions on the following which I have done in the past 
and perceive as different because the string constant is introduced and defined 
once and only once.

// my .m file
static NSString * const kMyContext = @"my fantastic context";

// later on
- (void) observeValueForKeyPath: (NSString *) keyPath   ofObject: (id) object
   change: (NSDictionary *) change context: (void *) context
{
  if ( context == kMyContext )
  { // do my stuff }
  else
  // call super
}

My interpretation of how to use context has been as an arbitrary pointer...  
Does this run afoul of anyone's sensibility?

Sandor Szatmari
___

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 update UI from a background thread

2016-09-21 Thread Sandor Szatmari
In general, one simple form is:

dispatch_async( dispatch_get_main_queue(), ^{
// do UI updates on the main thread.
});

This can also be done with NSOperationQueue:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
// do UI updates on main thread.
}];

Sandor Szatmari

> On Sep 21, 2016, at 11:40, Dave <d...@looktowindward.com> wrote:
> 
> Hi All,
> 
> How can I update my UI from a background thread?
> 
> I have a method that does a LOT of intense processing, it calls a delegate 
> method in my Window Controller which appends it to a Logging Scroll View, 
> however nothing shows up in the Scroll View although it NSLog’s the string ok.
> 
> Firstly is it ok to do this? When I tried it I got a CALayer error reported 
> in the NSLog output.
> 
> All the Best
> Dave
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Drawing issue with translucent borderless NSWindow, initial content half stays

2016-08-31 Thread Sandor Szatmari
Sean,

> On Aug 30, 2016, at 11:10, Sean McBride  wrote:
> 
> Hi all,
> 
> I have a drawing bug in my app, and reduced it to a toy app.  Basically, I 
> create an NSBorderlessWindowMask type window who's content view draws a 
> translucent rounded rect.  Its only subview is an NSTextField that draws a 
> number in a big font.  When I display the window, all is well.  But when I 
> change the textfield text, or even simply remove the textfield, its old 
> string half remains in a ghostly outline.  This works in 10.9 and 10.10, but 
> is buggy in 10.11 and 10.12.  I figure it's an OS bug, but maybe the 
> description rings any bells for anyone?  Code is here is someone cares to 
> look...:

To test whether it was some cached artifact I put the following lines at the 
end of -countdownTimerDidFire: and the artifact was not redrawn.

[[self window] orderOut:nil];
[[self window] makeKeyAndOrderFront:nil];

I'm not suggesting this as a solution, but as more context as to where the 
artifact is being held.

Sandor

> 
> 
> 
> Thanks,
> 
> -- 
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com 
> Mac Software Developer  Montréal, Québec, Canada
> 
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Mysterious crash with NSTableView

2016-08-26 Thread Sandor Szatmari
Doug,

> On Aug 26, 2016, at 17:58, Doug Hill <cocoa...@breaqz.com> wrote:
> 
>> On Aug 26, 2016, at 1:52 PM, Jens Alfke <j...@mooseyard.com> wrote:
>> 
>>> On Aug 26, 2016, at 8:42 AM, Andreas Falkenhahn <andr...@falkenhahn.com> 
>>> wrote:
>>> 
>>> But once again, I think it's a crime that there is no mentioning of this in 
>>> the class
>>> documentation of "setDelegate" and "setDatasource" :(
>> 
>> In the Xcode 8 docs for NSTableView.dataSource, it does:
>>"Note that in versions of OS X prior to v10.12, the table view did not 
>> retain the data source in a managed memory environment."
>> 
>> I’m sure I won’t be the first person to suggest that you switch to ARC. If 
>> you find ref-counting confusing, ARC will help you a lot.
>> 
>> —Jens
> 
> As usual, Jens speaks truthfully about using ARC.
> 
> However, in your case I wonder what the static analyzer in Xcode tells you 
> about the bug you see?

I believe Andreas mentioned he does not use Xcode as his product is cross 
platform, but this is a good suggestion.

Andreas,

If you add a static analysis phase to your Makefile does it help highlight 
these issues?

http://clang-analyzer.llvm.org

Sandor Szatmari

> Can it catch the bug? In manual ref-counting, the analyzer has saved my skin 
> more than once. :)
> 
> Doug
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Set the size of a sheet when it's first loaded

2016-08-25 Thread Sandor Szatmari
  
Shane,

> On Aug 25, 2016, at 04:28, Shane Stanley <sstan...@myriad-com.com.au> wrote:
> 
> I have a window that is shown as a sheet over another window. The sheet 
> contains a small table, and I want the sheet to be sized vertically to show 
> however many rows are required. So just before I show the sheet I update the 
> table and adjust the window's frame. This works fine -- except for the first 
> time the sheet appears, when it always appears with the size set in the nib.
> 
> I'm using autolayout, and I'm calling the code to set the window's frame

What are you calling to set the window's frame?  I am under the impression that 
calling setFrame: is not respected when using autolayout.

Sandor Szatmari

> and reload the table's data before showing the sheet (but after calling 
> window to ensure it's loaded). The table is being updated, but not the size. 
> I've also tried setting the frame in the sheet controller's windowDidLoad, 
> but that appears to be too late.
> 
> I'm sure I'm missing something simple... 
> 
> -- 
> Shane Stanley <sstan...@myriad-com.com.au>
> 
> 
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)

2016-08-11 Thread Sandor Szatmari
Quincey,

> On Aug 11, 2016, at 16:26, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
>> On Aug 11, 2016, at 12:50 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> I guess the answer is that the creation date property is not considered part 
>> of the 'meaning' of what the object is, and therefore would not be factored 
>> in when writing the -hash or -isEqual: methods.  This is perfectly 
>> reasonable, as many objects have properties that do not contribute in 
>> answering the question, is this object functionally equivalent.
> 
> After I posted, I realized I had merged two different questions. You had 
> first asked about examples of “this” in my original post:
> 
>> The fact than an object is immutable does not (in general) mean that a copy 
>> can be represented by the same object reference.
> 
> where I was talking only about references, and had nothing to say about 
> ‘hash’ or ‘isEqual:’. The creation date example was meant to show how a 
> different object reference might be needed for the copy.
> 
> But the question of ‘hash’ and ‘isEqual:’ stability was also raised by you 
> and others. This gets very hard very quickly, because (AFAIK) there is little 
> explicit constraint on what is allowed.
> 
> In particular, there is no absolute requirement about when an object’s ‘hash’ 
> value may change. That seems weird for immutable objects, but isn’t weird for 
> mutable objects. Indeed, the NSObjectProtocol documentation for ‘hash’ says 
> this:
> 
>> "If a mutable object is added to a collection that uses hash values to 
>> determine the object’s position in the collection, the value returned by the 
>> hash method of the object must not change while the object is in the 
>> collection. Therefore, either the hash method must not rely on any of the 
>> object’s internal state information or you must make sure the object’s 
>> internal state information does not change while the object is in the 
>> collection. Thus, for example, a mutable dictionary can be put in a hash 
>> table but you must not change it while it is in there. (Note that it can be 
>> difficult to know whether or not a given object is in a collection.)”

I couldn't have immediately pointed to the documentation, but this was the 
concern I has lurking in the back of my head; objects' -hash and -ieEqual: 
changing while in a collection.  Thanks for wrapping up the details so neatly!

The question raised that I couldn't quite find the words for is something like, 
if your copying collections and a constituent object's -copy method is called 
in the process, which alters the 'functional equality' of the collections, then 
things would break when relying on functional equivalency of the collections or 
their constituent objects.  I feel like this is answered now.

This means to me:

1. If at all possible, and within reason, avoid mutable objects in collections 
(your swift points address this).

2. You really need to be overtly aware of these details when designing classes 
and implementing -hash and -isEqual:

> 
> Strictly speaking, I see this as having two consequences:
> 
> 1. There may be NSCopying mutable objects that are always unsuitable for hash 
> tables, simply because they can’t meet the above requirement (because, for 
> example, you can’t stop them from changing while in a collection, because 
> their hash is based on dynamic factors outside your control).
> 
> 2. Since there is no *formal* distinction between mutable and immutable 
> objects, there is no formal constraint on either of:
> 
>   object.hash vs. object.copy.hash (== or not?)
>   [object isEqual: object.copy] (true or false?)
> 
> Although I think hash/isEqual issues are separate from the original question, 
> it’s very useful to have the subject raised, because:
> 
> a. It’s a great example of something that seems easy at a conceptual level, 
> but is very difficult in the details.
> 
> b. It’s a great reason why Swift (and other similar languages) place such an 
> emphasis on value types (“structs”) as opposed to reference types 
> (“classes”), and why Swift implements collections as value types rather than 
> reference types. 
> 
> In a large number of cases, the Obj-C conventions about hash, isEqual: and 
> copy are really about simulating value types with reference types. This works 
> well as long as we stay away from the sharp edges.
> 

I'm glad you made these points too!

Thanks,
Sandor
___

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: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)

2016-08-11 Thread Sandor Szatmari
Quincey,

Thanks for you additional thoughts...

> On Aug 11, 2016, at 14:11, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> I didn’t realize that I was saying anything controversial.
> 
>> On Aug 11, 2016, at 01:50 , Britt Durbrow 
>> <bdurb...@rattlesnakehillsoftworks.com> wrote:
>> 
>> Which, IMHO, means that *all* the values stored in the object must be the 
>> same.
>> 
>> By extension; [anObject hash] and [[anObject copy] hash] must return the 
>> same value; and [anObject isEqual:[anObject copy]] must return YES.
> 
> 
> “Stored in” is incorrect. What’s stored is an implementation detail. It’s 
> only the outward-facing values that matter. I believe your extension is also 
> technically false. See below.
> 
>> On Aug 11, 2016, at 04:22 , Dave <d...@looktowindward.com> wrote:
>> 
>> All non-object values should be identical, objects should be *functionally* 
>> identical (and *you* define what functional means, if you need the same 
>> creation date in one class and a new one in another that’s ok, they function 
>> differently).
> 
> Or they function the same. If I added the creation date solely as something 
> to look at in the debugger, the object and its copy are still functionally 
> identical as far as the app is concerned.
> 
>> On Aug 11, 2016, at 05:48 , Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Are there any real world examples of this in the Cocoa flora of objects?  If 
>> you had asked me before reading your response I would have called the 
>> behavior you describe a bug.  I would have said the result of -copy on an 
>> object should have the same -hash and return true for -isEqual:.
> 
> AFAIK, the only constraint is the one documented in the NSCopying protocol, 
> which was already quoted in this thread:
> 
>> "The exact meaning of “copy” can vary from class to class, but a copy must 
>> be a functionally independent object with values identical to the original 
>> at the time the copy was made.”
> 
> 
> The thing is, this isn’t much of a constraint, because there’s no restriction 
> on how tightly to interpret “identical” and “values”. In particular, AFAIK 
> there is no *formal* requirement that the copy have the same hash, or satisfy 
> ‘isEqual:' with its original. However, if copies aren’t ‘isEqual:’ to the 
> original, they can’t usefully work as NSDictionary keys, so this may be a 
> pragmatic, informal requirement, at least for utility classes.

I guess the answer is that the creation date property is not considered part of 
the 'meaning' of what the object is, and therefore would not be factored in 
when writing the -hash or -isEqual: methods.  This is perfectly reasonable, as 
many objects have properties that do not contribute in answering the question, 
is this object functionally equivalent.  I might have mistakenly promoted the 
creation date property in your example, giving it more import than it should 
have had.  Thanks for furthering the discussion.

Sandor

> 
>> Are there any real world examples of this in the Cocoa flora of objects?
> 
> 
> My example of an object that carries around its own creation date for 
> debugging purposes isn’t exactly an unreal world example.
> 
> Here’s another not-impossible scenario:
> 
> If you copied a NSNumber or NSString instance that happened not to be a 
> tagged pointer, but could be, it might be desirable for the ‘copy’ method to 
> detect the situation and return a tagged pointer.
> 
> Finally, the point of copy-by-incrementing-the-reference-count behavior is 
> *not* to make copying of objects practically free. The point is to make *a 
> copy of a copy* practically free. We often don’t know what object we’re 
> copying in the first place (we might be passed a NSString* parameter, but it 
> might actually be a NSMutableString instance), so the original copy might be 
> expensive.
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Objective-C basics - (Why NSNumber conforms to NSCopying protocol)

2016-08-11 Thread Sandor Szatmari
Quincey,

> On Aug 11, 2016, at 03:04, Quincey Morris 
>  wrote:
> 
>> On Aug 10, 2016, at 23:32 , Sasikumar JP  wrote:
>> 
>> what was the reason NSNumber conforms to NSCopying protocol.
> 
> 1. It actually inherits conformance from its superclass, NSValue.
> 
> 2. The fact than an object is immutable does not (in general) mean that a 
> copy can be represented by the same object reference. For example, an object 
> that contained its own date of creation might be immutable, but a copy might 
> have a different date, and therefore be a different object. Putting this 
> another way, the immutability does not make NSCopying conformance irrelevant.

Are there any real world examples of this in the Cocoa flora of objects?  If 
you had asked me before reading your response I would have called the behavior 
you describe a bug.  I would have said the result of -copy on an object should 
have the same -hash and return true for -isEqual:.  (Perhaps I need to expand 
my understanding here.)  Lastly, I would think if an object needed the behavior 
you describe, it would support this need with a special interface, like 
-duplicateWithCurrentDate.  Can you expound on this scenario?

> 
> 3. NSNumber is one of a group of classes that represent “serializable” 
> objects (for property lists, for example). Since these are often arranged in 
> heterogenous hierarchies using arrays, sets and dictionaries, it’s convenient 
> that they share behavior. If all property list classes conform to NSCopying, 
> then property lists can be deep copied without special code.
> 
> 4. Objects used as NSDictionary keys must conform to NSCopying. It would be a 
> hardship if this excluded NSNumber.
> 
> So it turns out to be easier to have NSNumber conform to NSCopying, than to 
> avoid conformance.
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Cocoa File Close Notification

2016-08-10 Thread Sandor Szatmari
Have you considered using a dispatch source?

You might have to do some manual checking when you get a notification about 
activity with your file, but it might be suitable to your needs.

Here's a link I was reading:

http://stackoverflow.com/questions/11355144/file-monitoring-using-grand-central-dispatch

Sandor Szatmari

> On Aug 10, 2016, at 15:30, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Aug 10, 2016, at 12:10 PM, Gurkan Erdogdu <gurkanerdo...@yahoo.com> wrote:
>> 
>> I try to get file close notification in Cocoa/Swift. Is there any way to do 
>> this? I tried to use FSEvent API but this does not provide any notification 
>> for file close events.
> 
> I don’t think there’s any such notification. File handles are private to a 
> process.
> 
>> Any help is appreciated. What I want to do is when word or PDF file is 
>> closed, I want my Cocoa application do sometnig?
> 
> If you want to do something when the file is changed, then watch for 
> file-changed events. You’ll probably want to wait a few seconds after the 
> last such event, because you may get several in a row if the changes take a 
> while (for example if a file is being downloaded.)
> 
> If you want to do something when a _document_ is closed in an app like 
> Preview or Word, that’s entirely different. Closing a document has nothing to 
> do with closing a file. When most apps open a document they open the file, 
> read its contents, and then close the file. They don’t leave it open while 
> the document is open. As far as I know there is no reliable way to detect 
> when some other app closes a document.
> 
> —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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Tracking down this annoyance

2016-07-03 Thread Sandor Szatmari
Graham, 

> On Jul 2, 2016, at 22:45, Graham Cox <graham@bigpond.com> wrote:
> 
> In my app, I ‘m getting this message logged now and again:

I see the same messages from a couple of apps.  I enabled the debugging as you 
did and investigated to know avail. I chalked it up to some framework code 
because all of the stack traces originated from outside my source.  If anyone 
has more insight I would love to eliminate these.

Sandor Szatmari

> CoreAnimation: warning, deleted thread with uncommitted CATransaction; 
> created by:
> 0   QuartzCore  0x7fff94e5c69a 
> _ZN2CA11Transaction4pushEv + 318
> 1   QuartzCore  0x7fff94e5c19a 
> _ZN2CA11Transaction15ensure_implicitEv + 276
> 2   QuartzCore  0x7fff94e62719 
> _ZN2CA5Layer13thread_flags_EPNS_11TransactionE + 37
> 3   QuartzCore  0x7fff94e62668 
> _ZN2CA5Layer4markEPNS_11TransactionEjj + 64
> 4   QuartzCore  0x7fff94e6412b 
> _ZN2CA5Layer25set_needs_display_in_rectERK6CGRect + 333
> 5   QuartzCore  0x7fff94e63fdc -[CALayer 
> setNeedsDisplayInRect:] + 25
> 6   AppKit  0x7fff9b0949ac -[_NSTiledLayer 
> setNeedsDisplayInRect:] + 210
> 7   AppKit  0x7fff9b14e4b8 
> -[_NSBackingLayerContents invalidateRect:] + 94
> 8   AppKit  0x7fff9ae79249 
> _NSBackingLayerSetNeedsDisplayInRect + 160
> 9   AppKit  0x7fff9ae791a3 -[_NSBackingLayer 
> setNeedsDisplayInRect:] + 61
> 10  AppKit  0x7fff9ae7998b 
> -[NSView(NSInternal) _setLayerNeedsDisplayInViewRect:] + 606
> 11  AppKit  0x7fff9ae4788e 
> NSViewSetNeedsDisplayInRect + 945
> 12  AppKit  0x7fff9ae474d6 -[NSView 
> setNeedsDisplayInRect:] + 48
> 13  AppKit  0x7fff9b1f10e3 
> -[_NSMirrorDocumentView documentViewNeedsDisplayInRect:] + 266
> 14  CoreFoundation  0x7fff91fbabbc 
> __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
> 15  CoreFoundation  0x7fff91fbab4f 
> ___CFXRegistrationPost_block_invoke + 63
> 
> 
> This is what I get having turned on the CA_DEBUG_TRANSACTIONS, otherwise I 
> get the first line without the stack trace.


> 
> It’s proving really awkward to track down - the problem is that a breakpoint 
> on, say -[_NSMirrorDocumentView documentViewNeedsDisplayInRect:] is called 
> all the time for many legitimate reasons, so I can’t pinpoint the one that 
> leads to this message. It would be helpful if I coud see what the 
> notification was that triggered this, but it’s NOT reported.
> 
> I’m guessing that this implies that a non-main thread has done something 
> UI-ish that it shouldn’t, like posting a -setNeedsDisplay. The app does use 
> plenty of threads, but I’ve been very careful to only do UI stuff on the main 
> thread, so I’ve been unable to track it down simply by reviewing the code. 
> Also, for all that, it seems benign - the app functions correctly AFAICS. I 
> would like to get rid of the message though.
> 
> Can anyone suggest a way I can debug this with a more targeted approach?
> 
> —Graham
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: NSTask argument list

2016-06-26 Thread Sandor Szatmari
Graham,

> On Jun 26, 2016, at 01:29, Graham Cox  wrote:
> 
> 
>> On 26 Jun 2016, at 3:22 PM, dangerwillrobinsondan...@gmail.com wrote:
>> 
>> If it helps, you can think of it  as an object oriented wrapped around C 
>> system calls that keeps track of PID and all the other bits like stdout and 
>> so on. 
>> That helps to grok why the args is and array and the tool is separate.
> 
> 
> Yep, it makes perfect sense, and is a good fit for my needs.
> 
> A follow up question, but this may be something that I’ll just have to grok 
> from the ffmpeg documentation - is there a way to get feedback from the 
> ffmpeg tool while it’s running, via NSTask? It writes a log to stderr, and 
> there are settings to control how verbose that is, but it would be necessary 
> to parse the text output to look for specific things. I need to know whether 
> the input stream has finished, or how big the output file has become. The 
> latter I may be able to do by looking at the file itself, not sure about the 
> first bit.

You can either asynchronously monitor the task's output with notifications, or 
I have read about a new API, but never used it, 
-setReadabilityHandler:^(NSFileHandle* file)

Sandor
> 
> —Graham
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: NSTask argument list

2016-06-26 Thread Sandor Szatmari
Graham,

> On Jun 25, 2016, at 23:37, Graham Cox  wrote:
> 
> HI all,
> 
> I am using NSTask to wrap ffmpeg, the video conversion utility.
> 
> I am able to invoke ffmpeg alright, but it’s unclear how the argument list 
> should be passed through NSTask. I tried making my various arguments into one 
> big string, but ffmeg doesn’t parse it, instead writing an error.
> 
> Here’s my code:
> 
>NSString* execPath = [[[self class] ffMPEGURL] path];
>
>NSString* argString = [NSString stringWithFormat:@"-i \"%@\" -c copy %@", 
> [url absoluteString], [self.outputFileURL absoluteString]];
>
>self.ffMPEGTask = [NSTask launchedTaskWithLaunchPath:execPath 
> arguments:@[argString]];

I believe you would pass the args to NSTask as follows.

self.ffMPEGTask = [NSTask launchedTaskWithLaunchPath:execPath 
arguments:@[@"-i",  [url absoluteString], @"-c", [self.outputFileURL 
absoluteString]]];

Type this in mail so it may not be exactly correct, but you get the idea.  Each 
token in your argument list is put in the argument array individually.

Sandor
> 
> 
> What the argument string should look like is:
> 
> -i  -c copy 
> 
> 
> ffmpeg responds:
> 
> Unrecognized option 'i "http://" -c copy file:/// file>'.
> Error splitting the argument list: Option not found
> 
> 
> Obviously I need to pass the arguments differently, but it’s not clear what I 
> need to do.
> 
> —Graham
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: XCode snapshot function?

2016-05-10 Thread Sandor Szatmari
Yes!

> On May 10, 2016, at 01:49, Jens Alfke  wrote:
> 
> 
>> On May 9, 2016, at 6:48 PM, Graham Cox  wrote:
>> 
>> So what’s the best way to mothball and archive my project in its current 
>> state so I can then fork it for the next version, and so on?
> 
> Git.  The Snapshot feature was basically made redundant once Xcode added 
> support for Git, so it makes sense that they removed it.
> 
> (That said, Xcode’s Git support isn’t the greatest. I strongly recommend 
> getting the free SourceTree app.)

SourceTree is great!  I still do small SCM operations in Xcode, like commits; 
its cherry picking for commits is great.  But I do push/pull/stash and 
branching/tagging from SourceTree.  It has made life so much better.  And it's 
free.

Sandor

> 
> —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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Very basic need, very difficult to achieve.

2016-05-06 Thread Sandor Szatmari
I can't say that this is complete or there won't be any gotchas for specific 
use cases, but here's what I can think of.

1. Preserving access in the App Store
If you don't "Purchase" the OS installer before the next release  you 
won't be able to download a new copy in the future.
So...
Whenever a new OS is released I "Purchase" the installer, download it, 
and archive it.
After it finishes downloading, the installer launches, quit the 
installer and copy the app to a safe permanent storage location.
Delete the installer application from /Applications
This process should make sure you have a local cache of installers and 
download access to the installer in the future through the App Store.
2. Creating Installers
In general, I just install on an external USB hard drive.  I use 16 GB 
USB sticks.
Here are some instructions
Lion and Mountain Lion

http://www.macworld.com/article/1167857/software-system/how-to-make-a-bootable-mountain-lion-install-drive.html
Mavericks and Beyond
https://support.apple.com/en-us/HT201372
Once I create an installer USB stick I keep it around, for the cost and 
headache its just easier.
3. Installing operating systems (Old and New)
Occasionally Apple introduces new hardware that does not support older 
OS's.
Occasionally Apple introduces new Software that does not support older 
hardware.
So, to be thorough, you need to maintain an awareness of what your 
hardware supports, and don't ditch your older machines so easily.
Virtual machines are a good work around if you don't have actual 
hardware that supports the OS you want to install on.  But there may be 
limitations.
4. Virtual Machines
Ever since Apple allowed virtualization Parallels and VMWare are great
Its nice to be able to take a snapshot and mess around break stuff and 
then rollback and test some more.
If you do a lot of work in virtual machines vagrant 
(https://www.vagrantup.com) is a pretty cool.  It facilitates rapid setup and 
switching between VMs.  It works with virtualbox and VMWare, not sure about 
Parallels.
There may be some limitations for specific development needs as some 
have pointed out, hardware acceleration support.  The only thing we trust at 
work is tests verified on actual hardware.


Sandor

> On May 4, 2016, at 08:29, Alex Zavatone <z...@mac.com> wrote:
> 
> Considering that we all will need to perform this joyous process when we 
> least expect it and have the least time to do it. Would it be possible to 
> bulletpoint the process to serve as a reference?
> 
> One thing I have noticed with some of the more recent versions of OS X (10.9 
> I think) is that once upgraded, HFS will no longer recognize volumes from 
> previous incarnations of the Mac OS.
> 
> This caused great panic on my end since it was unexpected, but it is 
> important to note if you are trying to install a prior OS to a volume where 
> the format or partition or whatever is not recognized by the HFS version of 
> the OS you are trying to install.
> 
> Just a nice detail.
> 
> To mitigate this pain, I keep several VMWare Fusion VMs around at 40 GB a 
> piece and when a new OS comes out, I duplicate the latest one, upgrade it, 
> install Xcode on it and move forward.
> 
> This way, I can always spoil up an older OS with a working version of Xcode 
> on it if needed.
> 
> Keeping these on a cheap and large HD and moving the one needed to an SSD is 
> a cost efficient manner of keeping working older OSes with functional Xcode 
> installs around if needed.
> 
> Hope this helps anyone who might have to go through Graham's lovely ordeal.
> 
> Cheers,
> 
> Alex Zavatone
> 
> Sent from my iPhone
> 
>> On May 4, 2016, at 7:41 AM, Sandor Szatmari <admin.szatmari@gmail.com> 
>> wrote:
>> 
>> Glad you got it to work.  I have seen the installer 'could not be verified' 
>> before.  The only time I saw that was after using command line copy (cp) to 
>> copy the installer app.  But except for that one experience, using 
>> createmediainstaller has worked well.  I also copy the installer to 
>> someplace outside /Applications like Phil (sqwarqDev) suggested before 
>> letting it run.  Basically the installer app that I archive is a pristine, 
>> never been run, download.  And then I make USB sticks directly off of those 
>> archived apps.
>> 
>> Sandor
>> 
>>> On May 4, 2016, at 01:33, Graham Cox <graham@bigpond.com> wrote:
>>> 
>>> 
>>>> On 3 May 2016, at 8:28 PM, Graham Cox <graham@bigpond.com> wrote:
>>>> 
>>>> So probabl

Re: Very basic need, very difficult to achieve.

2016-05-04 Thread Sandor Szatmari
Glad you got it to work.  I have seen the installer 'could not be verified' 
before.  The only time I saw that was after using command line copy (cp) to 
copy the installer app.  But except for that one experience, using 
createmediainstaller has worked well.  I also copy the installer to someplace 
outside /Applications like Phil (sqwarqDev) suggested before letting it run.  
Basically the installer app that I archive is a pristine, never been run, 
download.  And then I make USB sticks directly off of those archived apps.

Sandor

> On May 4, 2016, at 01:33, Graham Cox  wrote:
> 
> 
>> On 3 May 2016, at 8:28 PM, Graham Cox  wrote:
>> 
>> So probably a redownload isn’t going to help, but I’m doing it anyway.
> 
> 
> Success! Finally.
> 
> I created a new bootable installer using createinstallmedia and a fresh 
> Mavericks download. I did the Pacific Daylight Time change just in case 
> (though it sounds like voodoo, I’m prepared to believe anything at this 
> point…)
> 
> I was able to install from that disk without further problems and now have a 
> working Mavericks OS.
> 
> What didn’t work was trying to use the InstallESD.dmg directly. Creating a 
> copy of it using DU/Restore worked, but it only created a pure copy of the 
> disk image. That image was not bootable, and I was unable to make it so using 
> createinstallmedia nor the Ars instructions (which apply to earlier versions 
> of the OS anyway). It looks like the InstallESD approach is defunct from 
> 10.9, though there may be something I’m missing.
> 
> Thanks to everyone for their help.
> 
> It certainly shows that upgrading as new versions of the OS are released 
> should not be done without a great deal of thought. Leson learned.
> 
> —Graham
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

Re: Very basic need, very difficult to achieve.

2016-05-03 Thread Sandor Szatmari
Can you make a bootable USB drive and install from there?

https://support.apple.com/en-us/HT201372

Sandor Szatmari

> On May 3, 2016, at 19:28, Graham Cox <graham@bigpond.com> wrote:
> 
> My main dev machine runs the latest OS - 10.11.4
> 
> I need to install a 10.9 image on a disk partition for development testing.
> 
> How?
> 
> Apple’s dev site is getting worse all the time - wasting its time selling you 
> something you already have - OS X - but hiding away basic resources, like an 
> OS 9 installer that I can download. I’ve just spent 20 minutes fruitlessly 
> searching the dev site. It’s utterly baffling, taking you round and round in 
> circles.
> 
> How can I do this? Surely it’s actually possible, somehow?
> 
> Note that I do have an old Mavericks Installer, but it refuses to run on 
> 10.11, saying that the app is too old ro run on this version of the OS. I 
> also have not been able to set the partition I intend to use (that contains 
> the installer) as a startup disk. I seem to recall that there was a thread 
> about this not long ago, I even seem to remember pitching in something, but 
> now I come to need it myself, I can’t get it to work.
> 
> Very frustrating!
> 
> —Graham
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@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/archive%40mail-archive.com

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

  1   2   >