Re: Best Xcode machine mid-2019?

2019-07-02 Thread Alex Zavatone via Cocoa-dev
There used to be a control panel for this but Instruments lets you disable 
hyper threading and cores that is a systemwide setting.

The guys over at PSODFKit got distcc working with ccache for “stupid fast 
builds” in Objective-C.

https://pspdfkit.com/blog/2017/crazy-fast-builds-using-distcc/

Enjoy, 
Alex Zavatone

Sent from my iPad

> On Jul 2, 2019, at 10:47 AM, Richard Charles via Cocoa-dev 
>  wrote:
> 
> 
>> On Jun 28, 2019, at 9:39 PM, Dave Fernandes via Cocoa-dev 
>>  wrote:
>> 
>> Not a comprehensive list, but a start...
>> https://github.com/ashfurrow/xcode-hardware-performance
> 
> Very interesting. Thanks for sharing.
> 
> I was surprised to see Custom Hackintosh machines contributing to the Xcode 
> build performance data.
> 
>> On Jul 1, 2019, at 12:07 PM, Steve Mykytyn via Cocoa-dev 
>>  wrote:
>> 
>> Looking at Activity Monitor during the build, all four CPU cores are
>> utilized symmetrically, the four hyper-threads somewhat less.
> 
> I have an older Mac Pro (Quad-Core Intel Xeon) and the same thing happens. 
> During build the CPU scores are heavily used but the hyper-threads somewhat 
> less.
> 
> I always thought the physical cores and hyper-threads were used the same 
> amount, but that is not the case. Apparently the physical cores are more 
> powerful than the virtual cores. I never knew that.
> 
> --Richard Charles
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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: ARC

2019-08-23 Thread Alex Zavatone via Cocoa-dev
Casey, is this a Mac app or an iOS app?



> On Aug 23, 2019, at 4:17 PM, Casey McDermott via Cocoa-dev 
>  wrote:
> 
> We allocate the controller in our app delegate class

___

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

Please do not post admin requests or moderator comments to the list.
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: ARC

2019-08-23 Thread Alex Zavatone via Cocoa-dev
Casey, it it’s an iOS app, read up on strong and weak and use the storyboard to 
breat your first screen.  

Assuming it’s an iOS app…

Why are you allocating the controller in the app delegate?  Are you embedding 
it in a Nav controller?  

ARC is fantastic.  

The view controller is within the window.  I know I’ll need more info to help.



> On Aug 23, 2019, at 4:17 PM, Casey McDermott via Cocoa-dev 
>  wrote:
> 
> We started out assuming that ARC was like Python or Java, where you could 
> just allocate
> objects and it would manage their lifetimes automatically. Then we read about 
> the complexities
> of ARC, and started adding __weak to upstream references.
> 
> After we finished, the controller for our main window started being 
> deallocated some random time after launch.
> Apparently the erroneous strong references were keeping it alive.
> 
> We allocate the controller in our app delegate class. It's a member but 
> apparently that is not a 
> strong enough reference, so the controller is released at the end of the 
> scope. What is best practice to
> hold a strong reference on it until the app closes?
> 
> BTW, one site we looked at describes ARC as "kind of like a Japanese B-horror 
> movie". That seems accurate.
> 
> Casey McDermott
> TurtleSoft.com  
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Cocoa-dev Digest, Vol 16, Issue 72

2019-08-25 Thread Alex Zavatone via Cocoa-dev



> On Aug 25, 2019, at 7:49 PM, Turtle Creek Software via Cocoa-dev 
>  wrote:
> 
>>> Either you have files where ARC is still turned of (via the -fno-arc
> option
> 
> Nope, no compiler flags at all.
> 
>>> Make sure you're properly using NSBridgingRetain() etc. (or
> the equivalent typecasts) and not mixing them up.
> 
> In the hybrid C++/Obj-C++ files, we use __bridge on all the casts of void
> pointers to Cocoa objects.
> No use of NSBridgingRetain or Release at all.  Is that necessary under ARC?

I only remember using an autorelease pool when creating a view controller with 
access to the cameras but that was back in 2013.

I recommend creating a super simple app and see if the problem appears in the 
simple case.  

Alex Zavatone
___

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

Please do not post admin requests or moderator comments to the list.
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: NSLog displays inconsistent format for NSDate

2019-08-31 Thread Alex Zavatone via Cocoa-dev
Use an NSDateFormatter.  Use a format string with at the end ZZZ or  if you 
want the time zone offset added.




> On Aug 20, 2019, at 2:50 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> When printing out an NSDate using NSLog from within Xcode I get:
> 
> "Tue Aug 20 12:32:40 2019"
> 
> When the same program is run from within a shell (bash) window:
> 
> "2019-08-20 19:32:48 +"
> 
> Is the NSDate output format somehow determined by the environment? My system 
> is set to Local Time Zone (America/Los_Angeles (PDT) offset -25200 
> (Daylight)).
> 
> A code snippet that reproduces the issue follows. 
> 
> -Carl
> 
> 
> 
> - (void) testDate
> {
>NSCalendar *calendar = [NSCalendar currentCalendar];
>unsigned unitFlags = 
> NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute|NSCalendarUnitSecond|NSCalendarUnitTimeZone;
>NSDateComponents *dateComponents = [calendar components:unitFlags 
> fromDate:[NSDate date]];
>dateComponents.timeZone = NSTimeZone.localTimeZone;
>NSDate *configuredDate = [calendar dateFromComponents:dateComponents];
>NSLog(@"Configured date: %@",configuredDate);
> }
> 
> Xcode:
> 2019-08-20 12:32:40.828863-0700 tester[3926:1353] Configured date: Tue Aug 20 
> 12:32:40 2019
> 
> Shell:
> 2019-08-20 12:33:08.356 tester[3928:1359] Configured date: 2019-08-20 
> 19:32:48 +
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: ARC problems

2019-09-03 Thread Alex Zavatone via Cocoa-dev
Is it possible to switch out the view controller that i disappearing with 
another one and see if that also disappears?

Is that view controller voiding its own self reference?

> On Sep 3, 2019, at 5:18 PM, Turtle Creek Software via Cocoa-dev 
>  wrote:
> 
> The app delegate is NOT being deallocated prematurely- we have a breakpoint
> there to check.
> 
> We don't allocate the app delegate explicitly, so I had to set a breakpoint
> in init() to see when it happens.
> It's created in main() via NSApplicationMain.  Presumably its end of scope
> would be when main ends.
> The MainMenu.xib includes a Delegate object for our GSAppDelegate class, so
> it must be allocated
> via the nib-loading process (the stack trace says InitWithCoder).
> 
> GSAppDelegate has strong references to 4 window controller members: main
> window, prefs window, and a couple of log windows.
> But that alone has not kept the main window controller alive.  We haven't
> tested the others.
> 
> The main window controller that was mysteriously dying used to have a
> strong reference back to the app delegate.
> Whether strong, weak or non-existent, it didn't make any difference.  I
> suppose we could add a strong ref somewhere else
> just to be double safe, but I'm not sure where else would make sense.
> 
> The startup code was created 3 years ago when we were new to Cocoa,
> probably from one of the HIllegass books.
> It may have flaws, but the app has been running OK otherwise.  The problems
> only started when we read about circular references
> and started making up-references __weak.
> 
> BTW the Clang specs for ARC mention that it's not exception-safe.  If I
> understand correctly,
> strong references will leak, and weak references are released.  We don't
> throw any Cocoa exceptions but
> maybe the system does.
> 
> Casey McDermott
> 
> On Tue, Sep 3, 2019 at 4:24 PM Jean-Daniel  wrote:
> 
>> 
>>> Le 3 sept. 2019 à 02:33, Turtle Creek Software via Cocoa-dev <
>> cocoa-dev@lists.apple.com> a écrit :
>>> 
>>> Thanks for all the suggestions for the problems we had with a controller
>>> being
>>> deallocated unexpectedly under ARC.  Unfortunately, none of them fixed
>> it.
>>> 
>>> We do need to get back to regular app programming, so it will just stay a
>>> mystery.
>>> I was hoping we were doing something obviously dumb, but I guess the bug
>> is
>>> more subtle.
>>> 
>>> The app runs OK with the old code with multiple strong references to it
>>> They are circular references, but that controller sticks around for the
>>> full app lifetime.  Presumably any leakage
>>> won't happen until late in the game, anyhow.
>>> 
>>> Thanks,
>> 
>> Just a last suggestion. How is you App delegate created ? Do you keep a
>> strong ref on it. Else it will be deallocated and so will the controller.
>> 
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Screensaver icon ?

2019-09-17 Thread Alex Zavatone via Cocoa-dev
Add it in the build phases copy files phase or use the environment variables to 
build the path in a shell script and run that as part of your runtime build 
scripts.

Sent from my iPhone

> On Sep 17, 2019, at 10:20 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Thanks a lot for the response.
> 
>> So don't spend too much time on getting your screen saver icon to be
>> pixel perfect. The Desktop and Screen Saver pref pane will always do
> 
> OK, thanks a lot for your advice.
> I just thought I'd give it a quick shot, but couldn't figure it out :-)
> 
>>> looks like the file Contents/Resources/thumbnail.png (or .tiff) in the 
>>> bundle is used. If I replace this file it simply shows up.
> 
> How can I make Xcode to put an image into the Resources bundle of my screen 
> saver?
> 
> I have googled, found some hints about the "Asset Catalog" and an AppIcon 
> (iOS only?),
> but couldn't figure out how to make my image appear in the sidebar.
> 
> BTW: I have also checked the source code of xscreensaver , but could not 
> figure out how they do it.
> 
> 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/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: iOS play microphone to headphones

2019-10-08 Thread Alex Zavatone via Cocoa-dev
Doesn’t the user have to select the output device?

Sent from my iPhone

> On Oct 7, 2019, at 8:07 PM, Jens Alfke via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Oct 6, 2019, at 1:07 PM, Eric Dolecki via Cocoa-dev 
>>  wrote:
>> 
>> Quick Swift question. Is it fairly easy to take audio and play it to 
>> headphones (not a recording) and be able to turn the microphone on/off? I’m 
>> not interested in doing any analysis, just turning outside audio on/off.
> 
> That's an audio question, not a Swift question. And audio stuff is rarely 
> straightforward.
> 
> I don't think AVFoundation covers 'live' stuff like this — it's more about 
> recording and playback — so you're probably looking at the CoreAudio layer, 
> which is a fairly gnarly C API with a lot of complex C data structures. I 
> wouldn't think writing Swift glue for that would be easy at all :(
> 
> [Disclaimer: I haven't done any audio programming in a few years, so I may 
> not know about some wonderful new Swift-level audio API that makes this easy.]
> 
> —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/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: Alerts in Xcode 11

2019-10-09 Thread Alex Zavatone via Cocoa-dev
Just try it with the window code commented out.  

In any case, where you do have your code with the window, I would expect that 
you would make the window key and visible not manually adjust its layer and on 
dismiss, simply resign.

Alex Zavatone

Sent from my iPhone

> On Sep 30, 2019, at 4:48 PM, Doug Hardie via Cocoa-dev 
>  wrote:
> 
> Not sure how to do that.  It's not in any view controller as it is used in 
> virtually all of the various view controllers.  That's why I wanted it as a 
> function.
> 
> -- Doug
> 
>> On 30 September 2019, at 14:44, David Duncan  wrote:
>> 
>> What happens if you present it over your normal view controller hierarchy 
>> instead of using another window?
>> 
>> Has your application adopted UIWindowScene?
>> 
>>> On Sep 30, 2019, at 5:36 PM, Doug Hardie via Cocoa-dev 
>>>  wrote:
>>> 
>>> I have some code that presents an alert to the user with information they 
>>> need, and an OK button to clear it.  It works fine in the previous Xcode 
>>> versions.  However, after upgrading to 11, it now displays the alert and 
>>> then immediately clears it.  This happens both in the simulator and on a 
>>> real device.  I have played around with the code and can't figure out how 
>>> to make it leave the alert on the screen.  This is in Swift.  It is a 
>>> function that is called from numerous places in the app.
>>> 
>>> func NotificationAlert (_ msg1: String, _ msg2: String) {
>>>  let ErrorAlert = UIAlertController(title: msg1, message: msg2, 
>>> preferredStyle: .alert)
>>>  let dismiss = UIAlertAction(title: "Ok", style: .default, handler: nil)
>>>  ErrorAlert.addAction(dismiss)
>>>  ErrorAlert.presentInOwnWindow(animated: true, completion: nil)
>>> }
>>> 
>>> extension UIAlertController {
>>>  func presentInOwnWindow(animated: Bool, completion: (() -> Void)?) {
>>>  let alertWindow = UIWindow(frame: UIScreen.main.bounds)
>>>  alertWindow.rootViewController = UIViewController()
>>>  alertWindow.windowLevel = UIWindow.Level.alert + 1;
>>>  alertWindow.makeKeyAndVisible()
>>>  alertWindow.rootViewController?.present(self, animated: animated, 
>>> completion: completion)
>>>  }
>>> }
>>> 
>>> 
>>> -- 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/david.duncan%40apple.com
>>> 
>>> This email sent to david.dun...@apple.com
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Thoughts on Cocoa source code

2019-10-11 Thread Alex Zavatone via Cocoa-dev
It does the useful thing on 10.15.  I just had to add some scene code to our 
iOS app that had availability indicators around the methods indicating to use 
them on iOS 13 and greater.

Sent from my iPhone

> On Oct 9, 2019, at 1:39 PM, Aandi Inston via Cocoa-dev 
>  wrote:
> 
> " . Cocoa is part of the OS, and changes one very OS release. "
> 
> This reminds me of a question which pops up for me every few years in
> development. I can't call to mind the last
> specific details, but it will happen again.
> Let's create an imaginary problem:
> * Apple add a new class behaviour to Cocoa in macOS 10.15. We'll suppose
> they add [NSApplication doUsefulThing]
> * But for whatever reason, I'm using the Mac OS 10.14 SDK. So that will get
> a compile-time warning. Still, I'd
> really like to do the useful thing anyway, and without changing the SDK for
> whatever reason.
> * I add a check for actual OS version, so I am very sure not try to call
> [NSApplication doUsefulThing]
> unless the OS is 10.15 or later.
> * But what happens if it runs in 10.15? Does it actually do the useful
> thing?
> Are the Cocoa methods entirely dynamically loaded/provided by the live OS?
> Or does anything get statically linked,
> flagged, is the binary's SDK version checked or is there anything else that
> will prevent this call doing the
> useful thing?
> 
> Thanks in advance!
> 
> On Wed, 9 Oct 2019 at 18:42, Jens Alfke via Cocoa-dev <
> cocoa-dev@lists.apple.com> wrote:
> 
>> 
>> 
>>> On Oct 9, 2019, at 10:19 AM, Turtle Creek Software via Cocoa-dev <
>> cocoa-dev@lists.apple.com> wrote:
>>> 
>>> Why is Cocoa source code hidden?
>> 
>> So, take this as opinions of someone who worked at Apple, on [among other
>> things] Mac OS X apps from 2000-2007.
>> 
>> (a) It's part of Apple's crown jewels and seen as a competitive advantage.
>> (b) It calls all sorts of internal APIs of lower-level components like the
>> WindowServer, and Apple doesn't want to expose those APIs because they're
>> undocumented, easily misused, hard to support, subject to change at any
>> moment, etc.
>> (c) If developers look at the source code they'll be tempted to make use
>> of undocumented behaviors, private methods, etc. which makes their apps
>> much more likely to break in future OS versions. (This already does happen,
>> to an extent, but with source code it would be much more pervasive, given
>> the dynamic nature of Obj-C and how easy it is to call internal methods or
>> even patch system classes.)
>> (d) Internal source code tends to have comments and identifiers that refer
>> to internal code names, canceled projects, and other stuff that shouldn't
>> be made public. Sanitizing this is a pain.
>> (e) Apple obviously works on lots of features that remain secret for
>> months or years; these would all have to be kept in private branches,
>> causing all sorts of merging/rebasing headaches.
>> (d) It takes quite a lot of effort to maintain a large open source
>> project. It's not just dumping the source to Github.
>> 
>>> Yeah, the headers are visible, and Apple has
>>> info online. But sometimes that was not sufficient to understand the
>> actual
>>> implementation details.
>> 
>> You don't want to use the _implementation_ details! Those can and do
>> change completely over time — I know NSView has been
>> redesigned/reimplemented at least twice since 2000 — so making use of them
>> on OS version N could cause your app to break in version N+1. You want to
>> know the details of the (defined) _behaviors_. That means better
>> documentation. I agree that Apple could improve here.
>> 
>>> When debugging, the stack trace inside Cocoa was just a bunch of
>>> rarely-helpful Assembly. No way to set breakpoints inside Cocoa classes
>> 
>> That's not true; you can use symbolic breakpoints to break on any
>> Objective-C method, or any C function that has a visible symbol.
>> 
>>> I personally learned C++ while using the PowerPlant library from
>> Metrowerks.
>> 
>> The difference is that PP is code that you link statically into your app.
>> It doesn't change versions unless you explicitly update it. Cocoa is part
>> of the OS, and changes one very OS release. Binary compatibility is super
>> important to Apple, so Cocoa being a "black box" is actually a feature, not
>> a bug.
>> 
>> —Jens
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/aandi%40quite.com
>> 
>> This email sent to aa...@quite.com
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update

Re: Need for Swift

2019-10-11 Thread Alex Zavatone via Cocoa-dev


> On Oct 11, 2019, at 10:09 PM, Kirk Kerekes via Cocoa-dev 
>  wrote:
> 
> I would not want to be at the mercy of a vehicle piloted by C++. 

In the immortal words that I have in an email from John Carmack, “Failure in 
brakes.dll."
___

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

Please do not post admin requests or moderator comments to the list.
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-14 Thread Alex Zavatone via Cocoa-dev


> On Oct 14, 2019, at 1:25 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> The group that likes Obj-C sees Swift as being "arbitrarily syntactical" with 
> the syntax of the language getting in the way of programming. (There is a 
> third group that likes both languages, but it is very small.)

I am in this group.  The syntax of Swift just feels so arbitrary and to look 
deeper to solve more problems… if it weren’t for those compiler messages, it 
would be a mess.  I, for one shuddered when I saw “if let x = y” being 
something that people are expected to use and that damn, “you must unwrap this 
optional”, simply ends up making things that were simple in Objective-C, 
completely cumbersome in Swift.  

And this “everything is an extension”?  That is hell.  I love classes adopting 
protocols where the class definition of the variable must be weak, because you 
can’t do it in the protocol and oh, whar?  This proticol needs to be class 
backed?  

So much clunk to do what we could already do with ease.

But then again, my team is using VIPER and in none of the code reviews did the 
lead call in to question that every var was strong.  And they wonder why we had 
3410 memory leaks.

I’m not yet a fan.


___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev

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

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


Re: Need for Swift

2019-10-15 Thread Alex Zavatone via Cocoa-dev
The push for server side Swift is interesting in that it embodies the 
philosophy of moving Swift to other platforms/arenas.

Sent from my iPhone

> On Oct 15, 2019, at 8:57 AM, Turtle Creek Software via Cocoa-dev 
>  wrote:
> 
> This discussion about Swift vs Objective-C is interesting, but I think it
> omits something important. Both those languages only build apps for Apple
> products.
> 
> It's not such a big deal for iOS. iPhones are dominant enough that people
> can write just for that. Phone/pad apps are also relatively small, so a
> rewrite for Android is not too difficult if you want to go cross-platform.
> 
> For PCs it's a different story. Mac has about 10% market share overall, but
> it varies. In our market, architects are about 20% Mac, engineers less than
> 1%, construction maybe 2%.  The apps are bigger and more complex.  Nobody
> is every going to write a full CAD, project management or business
> accounting app in either Swift or Obj-C.
> 
> TurtleSoft has a big investment in C++ source code that's full of
> construction business logic. Unfortunately, with the death of Carbon its
> future value is in doubt.
> 
> I just checked a half dozen sites that measure popularity of programming
> languages. The Stack Overflow survey seemed the best, since they directly
> asked folks what they use. For 2019, their top 5 app-development languages
> are Python, Java, C#, C++ and C in that order. 42% of respondents use
> Python, down to 20% for C. Interestingly, there is a huge gap after that.
> Their next most popular app-dev language is Go at 8.8%. Swift rated 6.6%
> and Objective-C was 4.8%. Then there is a long, long tail of other
> languages with a few % or less.
> 
> PYPL puts the top 5 in the same order. TIOBE index ranks them as Java, C,
> Python, C++, C#. Both those lists put Obj-C ahead of Swift, with the Apple
> languages well ahead of Go.
> 
> Popularity is important. Those top few languages are frequently-used for
> reasons. Many people and organizations are working to improve them. High
> schools and colleges teach them. They have a wide range of books and
> tutorials. Good libraries and open source projects. Lots of blogs and Stack
> Overflow answers. Job opportunities. Success breeds success.
> 
> I think it's fair to say that Python, Java and C++ deserve special respect
> because they dominate so much. Call them the "mainstream". I'm excluding C
> because it's more often used for low-level work, and C# because it's mostly
> limited to Microsoft's ecosystem.
> 
> The minor languages certainly have their fanatics. Some have corporate
> sponsors. I'm sure Apple has fantastically talented and dedicated engineers
> working on Swift and Objective C. Both have many good features. But they
> are minority languages. It has an impact. We bought every book in existence
> about Objective C and Swift. Read close to everything we could find online.
> Looked at every archived post on this list. Built all of Apple's example
> apps. It still wasn't enough to help us finish a Cocoa conversion in time.
> 
> Even worse, the future for Mac is starting to look like a required Swift
> front end to get new features (and maybe ARM compatibility). Using C++ at
> all means having Objective-C in the middle. It just gets too complicated.
> 
> Yesterday I checked up on a few other companies we know who have Mac
> software in the AEC market.  Most died off years ago. Two are now
> Windows-only. Three will have 64-bit apps "soon". So far, nobody is ready
> for Catalina yet.
> 
> Casey McDermott
> TurtleSoft.com
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Need for Swift

2019-10-15 Thread Alex Zavatone via Cocoa-dev


Sent from my iPhone

> On Oct 15, 2019, at 10:37 AM, John Joyce via Cocoa-dev 
>  wrote:
> 
> 
> 
>> 
>> On Oct 15, 2019, at 22:58, Turtle Creek Software via Cocoa-dev 
>>  wrote:
>> 
>> Nobody
>> is every going to write a full CAD, project management or business
>> accounting app in either Swift or Obj-C.
>> 
>> TurtleSoft has a big investment in C++ source code that's full of
>> construction business logic. Unfortunately, with the death of Carbon its
>> future value is in doubt.
> If your code is worth complaining about this much, then move to Objective-C++ 
> and wire up a damn UI. That or Electron, wxWidgets or Qt or one of the 
> plethora of mostly abysmal cross platform GUI toolkits. 
> It’s getting old and it’s just a drag for everybody. 
> Carbon is dead and nobody was surprised by this but your company somehow. 
> Everybody else got the memo a decade ago. Spam this list less and go do some 
> coding. 

I think what the benefit could be is to see the problems he has and sharing 
options to address them - just as you did.

Is it possible to approach this on a module by module approach?

If he were to take your approach, how would you recommend he start?

Cheers.  Back to hell for me.
Alex Zavatone



> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Need for Swift

2019-10-15 Thread Alex Zavatone via Cocoa-dev


Sent from my iPhone

> On Oct 15, 2019, at 7:25 AM, Sandor Szatmari  
> wrote:
> 
> Obj-C represents the freedom for me to write bad code if I need to…

Believe me, I have been living in the results of the bad code that Swift allows 
developers to create.  Debugging how a tap in a UITableViewCell actually gets 
back to the view controller took me a day to wade through the excessive 
spaghetti when target : action and a weak ref to the VC or object that handles 
the action is painfully easy and does not introduce excess unneeded hard to 
debug code.

Swift is not a cure-all. That’s for sure.



___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev


> On Oct 15, 2019, at 6:08 PM, Charles Srstka via Cocoa-dev 
>  wrote:
> 
> Seeing lots of `!` in production Swift is a code smell.
> 
> Charles

I wouldn’t call it a code smell.  It’s worse.  It’s actually asking for a crash 
if everything doesn’t work out perfectly and an expected result is nil.  And 
that’s exactly what will happen.


___

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

Please do not post admin requests or moderator comments to the list.
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-16 Thread Alex Zavatone via Cocoa-dev


> On Oct 16, 2019, at 4:49 AM, Stephane Sudre via Cocoa-dev 
>  wrote:
> 
> Why do Swift developers think it's mandatory to write code that is illegible?
> Is Swift mainly used by freelances or consultants that will not have
> to maintain the software?

The zest to do things in a way, “because it is Swifty”.  

That doesn’t mean that it is good.  And people insist that “because it is 
Swifty”, it must be the new best thing and clearly everyone else “just doesn’t 
understand the new way”.

It’s pretty arrogant, but that’s what I’ve seen as well.  People need to 
evaluate a new approach and based upon their experience, decide if it is a good 
thing.  Honestly, our developers want to rush to SwiftUI and embrace everything 
new without realizing that we still need to support users running iOS 10.  

Anyway, It’s an enthusiastic jump to adopt the new without considering what 
about it is wise to do.
___

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

Please do not post admin requests or moderator comments to the list.
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: Alerts in Xcode 11

2019-10-16 Thread Alex Zavatone via Cocoa-dev
Yeah, one thing you need to do is get the key window’s presentedViewController. 
 You can do this from the shared applicationDelegate.  Create a standalone 
class that gets UIApplication.shared().keywindow.presentedViewController.  
Think of that as self.  And then use that to present the alert.  Add a weak 
reference back to whichever object you need to do stuff when buttons are 
pressed in that alert.

Hope this helps.

> On Oct 16, 2019, at 6:00 PM, Doug Hardie via Cocoa-dev 
>  wrote:
> 
> I finally got some time to get back to this again.  The extension does a lot 
> of what I need.  It works great if it is called from any UIViewController.  
> However, if I call it from a function that is not in a view controller then 
> Swift says notificationAlert is not defined.  There is another side effect 
> that is more problematic, When the alert is displayed, I also get the message:
> 
> popViewControllerAnimated: called on  
> while an existing transition or presentation is occurring; the navigation 
> stack will not be updated.
> 
> Generally these alerts are used when a user tries to enter a view controller 
> where the prerequisite data has not been provided.  I wanted the alert to 
> display and then go back to the previous view controller.  I suspect that I 
> will need to use completions in the notificationAlert function to do that 
> rather than just following the call with the stack pop.
> 
> -- Doug
> 
>> On 9 October 2019, at 07:40, davel...@mac.com wrote:
>> 
>> I'm by no means an expert but if I understand what you're trying to do, I 
>> think the approach I would take is to make an extension on UIViewController:
>> 
>> extension UIViewController {
>>   func notificationAlert(_ msg1: String, _ msg2: String) {
>> 
>>   // create the UIAlertAlertController
>>   // and then do as David Duncan said and do:
>>   self.present(, animated:  completion: …)
>>   }
>> }
>> 
>> Now all your UIViewController subclasses can call that method (and because 
>> it's a method, they have access to self which is a subclass of 
>> UIViewController).
>> 
>> HTH,
>> Dave
>> 
>> 
>>> On Sep 30, 2019, at 11:27 PM, Doug Hardie via Cocoa-dev 
>>>  wrote:
>>> 
>>> I tried that and swift complains that self is not defined.  This is not in 
>>> a view controller but a stand alone function used in many view controllers. 
>>>  Generally it is used during a segue, but I added one in a view controller 
>>> to a button action, not part of a segue and it dismissed the alert also.  
>>> 
>>> -- Doug
>>> 
 On 30 September 2019, at 19:48, David Duncan  
 wrote:
 
 Instead of creating a new window and a root view controller in order to 
 present your alert, just use (assuming self is a UIViewController) 
 self.present(, animated:  completion: …)
 
> On Sep 30, 2019, at 5:48 PM, Doug Hardie  wrote:
> 
> Not sure how to do that.  It's not in any view controller as it is used 
> in virtually all of the various view controllers.  That's why I wanted it 
> as a function.
> 
> -- Doug
> 
>> On 30 September 2019, at 14:44, David Duncan  
>> wrote:
>> 
>> What happens if you present it over your normal view controller 
>> hierarchy instead of using another window?
>> 
>> Has your application adopted UIWindowScene?
>> 
>>> On Sep 30, 2019, at 5:36 PM, Doug Hardie via Cocoa-dev 
>>>  wrote:
>>> 
>>> I have some code that presents an alert to the user with information 
>>> they need, and an OK button to clear it.  It works fine in the previous 
>>> Xcode versions.  However, after upgrading to 11, it now displays the 
>>> alert and then immediately clears it.  This happens both in the 
>>> simulator and on a real device.  I have played around with the code and 
>>> can't figure out how to make it leave the alert on the screen.  This is 
>>> in Swift.  It is a function that is called from numerous places in the 
>>> app.
>>> 
>>> func NotificationAlert (_ msg1: String, _ msg2: String) {
>>> let ErrorAlert = UIAlertController(title: msg1, message: msg2, 
>>> preferredStyle: .alert)
>>> let dismiss = UIAlertAction(title: "Ok", style: .default, handler: nil)
>>> ErrorAlert.addAction(dismiss)
>>> ErrorAlert.presentInOwnWindow(animated: true, completion: nil)
>>> }
>>> 
>>> extension UIAlertController {
>>> func presentInOwnWindow(animated: Bool, completion: (() -> Void)?) {
>>>  let alertWindow = UIWindow(frame: UIScreen.main.bounds)
>>>  alertWindow.rootViewController = UIViewController()
>>>  alertWindow.windowLevel = UIWindow.Level.alert + 1;
>>>  alertWindow.makeKeyAndVisible()
>>>  alertWindow.rootViewController?.present(self, animated: animated, 
>>> completion: completion)
>>> }
>>> }
>>> 
>>> 
>>> -- Doug
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Coc

FYI: info on our scary Mac rebooting iOS testing crash.

2019-10-17 Thread Alex Zavatone via Cocoa-dev
As a background, I mentioned that we occasionally have these scary crashes 
while running our iOS tests that either reboot your Mac or crash the user 
process out to the login screen.

Yesterday, I noticed that I could not run our tests at all without crashing 
around a certain area and on 3 different Macs, all with 24 GB or more of RAM.

My speculation that it, might be related to mach ports was entirely correct as 
after 8 crashes, some debug logs finally appeared - but not all the time.

Our iOS UI tests are run by KIF which uses XCTest as its foundation.  When 
running these 280+ UI automation scripts in the Simulator, the amount of ports 
used by Xcode increased rapidly as the tests ran for 30 mins and the 
WindowServer process appeared to have about 20,000 more Mach ports allocated 
than Xcode over that time.  

Right before the crash happened, the WindowServer had allocated over 256,000 
ports and Xcode was just behind by a few thousand.  Then, all operation pauses 
for a few seconds, the displays go black, and a few seconds later, the user 
login screen appears as the previous user session crashed out.  

What happened is that Xcode asked for more ports and asked the WindowServer to 
allocate more ports and the WindowServer asked the GPU driver for more ports 
and thread com.apple.SkyLight.mtl_submit to crash with either a SIGSEV or 
SIGILL.  Either the WindowServer or the Skylight framework for MetalDevice and 
caused a GPU restart.  The OS then crashed the user session out to the login 
screen.

Now, the question.  Why the hell is XCTest causing Xcode to request so many 
Mach ports and never release them until the app is quit or the system crashes?

I tested this last night outside of our app with XCTest and KIF simply going 
back and forth between two screens in an iOS app several thousand times In the 
Simulator. The mach ports of both Xcode and the WindowServer go up and are not 
released until the app quits, but not nearly as fast as in our tests.  
Is this a mach port leak in XCTest?  

Does anyone know the details on the guts of this?

Thanks a lot and I hope this helps someone else. 

Alex Zavatone

Sent from my iThing.
___

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

Please do not post admin requests or moderator comments to the list.
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: FYI: info on our scary Mac rebooting iOS testing crash.

2019-10-18 Thread Alex Zavatone via Cocoa-dev
Wow was this ever fun.

Woo hoo!

Let this be an exercise in the dangers of memory leaks.

Our team uses VIPER with everything being strongly linked. Also in Objective-C, 
there are cases where private instance variables are used, not the wrapping 
properties, not to mention strongly referenced delegates. Who needs memory 
management, right? Well, guess what? When you do this, it's really easy to leak 
lots of objects and this means lots of mach ports are requested from Xcode and 
this means that there are lots of mach ports requested by the WindowServer and 
this means that the GPU driver, (SkyLight) requests more mach ports - until the 
system says, "no, you can not have any more.”  That happens around 260,000+ 
mach ports in the WindowServer. This restarts the GPU. And when the GPU 
restarts, the system either restarts the Mac or crashes the user session out to 
the login screen.

After a night fixing memory bugs until midnight, I ran our 280 KIF tests and no 
more than 20,000 mach ports were requested. And the full test ran all the way 
through without rebooting the Mac or crashing out to the login screen.  

Memory leaks matter!

Oh, and if anyone wants video of watching the Mac reboot when the WindowServer 
has over 260,000 mach ports allocated, I'll happily post a link.

Cheers,

Alex Zavatone

> On Oct 17, 2019, at 12:07 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> As a background, I mentioned that we occasionally have these scary crashes 
> while running our iOS tests that either reboot your Mac or crash the user 
> process out to the login screen.
> 
> Yesterday, I noticed that I could not run our tests at all without crashing 
> around a certain area and on 3 different Macs, all with 24 GB or more of RAM.
> 
> My speculation that it, might be related to mach ports was entirely correct 
> as after 8 crashes, some debug logs finally appeared - but not all the time.
> 
> Our iOS UI tests are run by KIF which uses XCTest as its foundation.  When 
> running these 280+ UI automation scripts in the Simulator, the amount of 
> ports used by Xcode increased rapidly as the tests ran for 30 mins and the 
> WindowServer process appeared to have about 20,000 more Mach ports allocated 
> than Xcode over that time.  
> 
> Right before the crash happened, the WindowServer had allocated over 256,000 
> ports and Xcode was just behind by a few thousand.  Then, all operation 
> pauses for a few seconds, the displays go black, and a few seconds later, the 
> user login screen appears as the previous user session crashed out.  
> 
> What happened is that Xcode asked for more ports and asked the WindowServer 
> to allocate more ports and the WindowServer asked the GPU driver for more 
> ports and thread com.apple.SkyLight.mtl_submit to crash with either a SIGSEV 
> or SIGILL.  Either the WindowServer or the Skylight framework for MetalDevice 
> and caused a GPU restart.  The OS then crashed the user session out to the 
> login screen.
> 
> Now, the question.  Why the hell is XCTest causing Xcode to request so many 
> Mach ports and never release them until the app is quit or the system crashes?
> 
> I tested this last night outside of our app with XCTest and KIF simply going 
> back and forth between two screens in an iOS app several thousand times In 
> the Simulator. The mach ports of both Xcode and the WindowServer go up and 
> are not released until the app quits, but not nearly as fast as in our tests. 
>  
> Is this a mach port leak in XCTest?  
> 
> Does anyone know the details on the guts of this?
> 
> Thanks a lot and I hope this helps someone else. 
> 
> Alex Zavatone
> 
> Sent from my iThing.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Swift -> Obj-C: return __kindof Something

2019-11-11 Thread Alex Zavatone via Cocoa-dev
You should be able to look at the header in Swift for your Objective-C class 
and see what it should be.

> On Nov 11, 2019, at 8:06 PM, Steve Christensen via Cocoa-dev 
>  wrote:
> 
> Yep, I understand what it does. I’m trying to get the same class-or-subclass 
> behavior during compilation. I’d looked at the stack overflow article 
> earlier, so I’ll check out the Swift forum to see what’s there. Thanks.
> 
>> On Nov 11, 2019, at 4:43 PM, Quincey Morris 
>>  wrote:
>> 
>>> On Nov 11, 2019, at 15:07 , Steve Christensen via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> Some existing Obj-C methods are of the form:
>>> 
>>> + (nullable __kindof NSManagedObject) someFooThing;
>>> 
>>> Right now I have
>>> 
>>> class var someFooThing: NSManagedObject?
>> 
>> AFAIK, “__kindof” only affects the ability to assign one Obj-C class pointer 
>> to a variable of a different but compatible (kind of) type. It doesn’t 
>> change the actual type of the variable, nor does it (again AFAIK) change the 
>> ability to assign without errors in Swift. Also see here for some 
>> informative discussion:
>> 
>>  https://stackoverflow.com/questions/31399208/ios-kindof-nsarray 
>> 
>> 
>> I suggest you ask about this on forums.swift.org . 
>> If there’s an alternative, someone there will know.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Thoughts on Objective-C++

2019-11-13 Thread Alex Zavatone via Cocoa-dev


> On Nov 13, 2019, at 2:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> be a good time for a SwiftUI pivot. If true, Cocoa is the new Carbon.
>> 
> 
> I think, eventually, maybe in 5 years' time, that will be the case.
> This is really just a guess, I have no insights into Apple's roadmap.

Back before Steve brought Phil back to Apple, we worked together at Macromedia.
Phil mentioned to me in about 1996, 1997 back at Macromedia that it was the 
goal for Apple to turn computers into the equivalent o kitchen appliances.  You 
won’t upgrade your computer, you will just buy a new appliance.  

We’re still on the pathway there.

It’s better for Apple as a company, but personally, I’d rather be able to 
upgrade my devices.

Cheers,
Alex Zavatone

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Thoughts on Objective-C++

2019-11-13 Thread Alex Zavatone via Cocoa-dev



> On Nov 13, 2019, at 6:28 PM, Turtle Creek Software via Cocoa-dev 
>  wrote:
> 
> Convert resources from ResEdit 

DUDE.  This is what, 20 years overdue?
___

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

Please do not post admin requests or moderator comments to the list.
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-dev Digest, Vol 16, Issue 144

2019-11-14 Thread Alex Zavatone via Cocoa-dev
Not to create a conflict, but I like to think about it this way.  I had to do 
it with my parents as they approached their elderly years and we have to do it 
whenever the next version of Swift and Xcode come out. 

A train is moving to a cliff.  The cliff is far away but eventually, if you do 
nothing, the train is going straight off the cliff.

We know it's coming.  You’re faced with one option an other.  The longer you 
wait, the closer the train is to the edge of the cliff.

It’s a business reality that we all face in one form or another.

If I ignored the business realities facing me 20 years ago, I’d still be 
programming in Lingo and waiting for someone to give me a contract to build a 
Shockwave app.

Hopefully there is still time divert the train.  Best of luck.

Alex

> On Nov 14, 2019, at 8:11 AM, Turtle Creek Software  
> wrote:
> 
> >> >> Convert resources from ResEdit 
> >> DUDE.  This is what, 20 years overdue?
> 
> Dude.  Why would we change them before it was necessary?  Don't fix it if it 
> ain't broke.  There were better things to work on in the past 20 years.
> 
> We wrote code to go through each type of resource and convert them to XML. 
> Then that turned out to be a huge PITA to maintain, so we revised it to tab 
> text.  Easy to revise in Excel and 10x faster to load. 
> 
> My question is, why on earth didn't Apple provide a conversion tool like 
> that?  It would have saved thousands of developers from having to write their 
> own resource translators or do it by hand. 
> 
> Casey McDermott
> TurtleSoft.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: Permission Denied trying to connect to localhost in unit test

2019-12-13 Thread Alex Zavatone via Cocoa-dev
Is it an https/http error?  

On iOS, we have to add an exception in the info.plist for ATS (Application 
Transport Security) to allow http traffic.

Is there anything similar on the Mac?

Sent from my iPhone

> On Dec 12, 2019, at 12:58 PM, Jens Alfke via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Dec 12, 2019, at 7:42 AM, Robert Walsh via Cocoa-dev 
>>  wrote:
>> 
>> I am writing a command line application in Objective-C that needs to make a 
>> TCP connection to a server.  In a unit test for the TcpClient class I am 
>> writing, I have a simple TCP server that listens for connections in a 
>> thread.  When I try to connect to this socket from the client socket class, 
>> connect() fails and perror reports Permission Denied. 
> 
> That's odd. I've written plenty of macOS networking code and not seen this 
> problem. What is the errno value?
> 
> The only thing I can guess is that the Xcode test-runner process is being 
> sandboxed to prevent outgoing networking, but I've definitely run TCP 
> connections from XCTests without problems. Are you connecting to "localhost" 
> / 127.0.0.1, or using an explicit IP address?
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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: Embedded binary is not signed with the same certificate as the parent app

2020-03-03 Thread Alex Zavatone via Cocoa-dev
Why are you copying that app you are trying to build?

Sent from my iPhone

> On Mar 3, 2020, at 1:11 PM, Gabriel Zachmann  wrote:
> 
> Thanks a lot for your response!
> 
> Here is the screenshot:
> 
> 
> In case the mailing list deletes the screenshot, here is a link :
> 
>   https://owncloud.informatik.uni-bremen.de/index.php/s/25r8p7kDWqtpgnY
> 
> 
> If you are curious, here is the source: 
>https://owncloud.informatik.uni-bremen.de/index.php/s/6jZ7rqFGkZ53fsA
> 
> 
> 
> There are no libraries inside the package , just the bare minimum:
> 
> Contents% ls -R
> Info.plistMacOS/  PkgInfo Resources/  _CodeSignature/
> 
> ./MacOS:
> ArtSaverApp*
> 
> ./Resources:
> Base.lproj/
> 
> ./Resources/Base.lproj:
> MainMenu.nib
> 
> ./_CodeSignature:
> CodeResources
> 
> 
> 
>> I still think that my previous advice of finding out which lib you are using 
>> and turning off code signing for it is the easiest approach.
> 
> 
> I am linking to a number of macOS libraries (although not using them in the 
> code yet):
> Photos, CoreLocation, QuartzCore, ApplicationServices, IOKit, AppKit, 
> Foundation, MediaLibrary, Cocoa.
> 
> I am not using any other libraries.
> 
> How can I turn off code signing for one of those libraries?
> 
> 
> 
> Best regards, Gabriel
> 
> 
> 
> 
>> On 3. Mar 2020, at 12:47, Alex Zavatone  wrote:
>> 
>> Please send a screenshot of your copy files phase so we can clearly see what 
>> you are trying.
>> 
>> Thanks.
>> 
>> Sent from my iPhone
>> 
>>> On Mar 2, 2020, at 7:12 PM, Gabriel Zachmann via Cocoa-dev 
>>>  wrote:
>>> 
>>> I have a naked macOS app (created with Xcode's template "App").
>>> 
>>> I get this funny error message
>>> 
>>>   Embedded binary is not signed with the same certificate as the parent app
>>> 
>>> but only, when I switch to Release *and* when I add a Copy Files phase
>>> with   Destination = Absolute Path
>>> and   Name = MyProduct.app
>>> When I compile the Debug version, everything is fine.
>>> 
>>> I don't think I have an "embedded binary".
>>> 
>>> One thing that is funny is that in the table of the Copy Files phase, it 
>>> says "...in build/Debug".
>>> 
>>> So I guess I am doing something wrong when I define the Copy Files phase.
>>> I just want to copy the executable to a different place directly after 
>>> compilation.
>>> 
>>> Have googled, to no avail.
>>> 
>>> Could some kind soul explain to me, please, how to define a proper "Copy 
>>> Files" phase in XCode 11?
>>> 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/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: applicationDidFinishLaunching not being called

2020-03-09 Thread Alex Zavatone via Cocoa-dev
Dave, I just selected the AppDelegate in the storyboard in a temp app, deleted 
it and the AppDelegate methods are skipped.

I’m guessing that your answer is the one that’s causing it, as in my 
suggestions, the console throws a descriptive error message.



> On Mar 9, 2020, at 7:31 PM, Dave via Cocoa-dev  
> wrote:
> 
> Look at the Application Object in the Workspace/NIB file, is the class 
> AppDelegate? If not it should be! Do you have an AppDelegate in the 
> project/target and is the correct target set for it?
> 
> BTW, these questions are better posted to the Xcode list.
> 
> All the Best
> Dave
> 
> 
>> On 9 Mar 2020, at 17:55, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> I must have done something very stupid, accidentally,
>> but the method applicationDidFinishLaunching in my AppDelegate is not being 
>> called any more.
>> 
>> I have googled and tried a few things, of course, to no avail.
>> 
>> Does anyone have an idea what it might be?
>> Maybe, some kind soul can take a quick look at my source code:
>> https://owncloud.informatik.uni-bremen.de/index.php/s/Yc67zM8ikBZFnRc
>> which is still pretty bare.
>> 
>> 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/dave%40looktowindward.com
>> 
>> This email sent to d...@looktowindward.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Open a panel in secondary thread?

2020-03-21 Thread Alex Zavatone via Cocoa-dev
Isn’t the main thread meant for updating the UI?

> On Mar 21, 2020, at 7: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/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: Open a panel in secondary thread?

2020-03-23 Thread Alex Zavatone via Cocoa-dev
Main queue is analogous to the main thread, but not exactly the same - 
according to Apple’s docs.

Sent from my iPhone

> On Mar 23, 2020, at 12:53 PM, 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?
> 
> 
>> 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.
> 
> 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/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: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Are you ever removing your timers?

Quit Xcode, reload the project and see if the same thing happens.



> On Apr 29, 2020, at 3:36 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> When I issue NSTimer's +timerWithTimeInterval: method, I'm getting 
> unexpected timer firing times (20X faster than expected).
> 
> ∙ If I specify 1.0 for the time interval, my method gets called 20 times/sec. 
> ∙ If I specify 20.0 for the time interval, my method gets called 1 time/sec.
> ∙ If I specify 100.0 for the time interval, my method gets called 5 times/sec.
> ...etc.
> 
> Here is my only invocation, called once and nevermore:
> 
>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];
> 
> How can this be?  NSTimeInterval is supposed to be in seconds!
> 
> From the Apple documentation:
> 
> + (NSTimer 
>  
> *)timerWithTimeInterval:(NSTimeInterval 
> )ti
>  
>target:(id)aTarget 
>  selector:(SEL)aSelector 
>  userInfo:(id)userInfo 
>   repeats:(BOOL)yesOrNo;
> Parameters
> ti
> The number of seconds between firings of the timer. If ti is less than or 
> equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds 
> instead. A NSTimeInterval value is always specified in seconds; it yields 
> sub-millisecond precision over a range of 10,000 years.
> 
> I can accommodate this odd behavior in my code, but something's gotta be 
> wrong...
> -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/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: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Not sure about this, but in Objective-C, you’re not supposed to start methods 
with new.

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

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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
I used your code in an iOS project and it works as expected.

2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 2020
2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 2020
2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 2020
2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 2020
2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 2020
2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 2020
2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 2020
2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 2020
2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 2020

I’ll mail you the project offlist.



> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
>> 
>> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>>>  wrote:
 
 When I issue NSTimer's +timerWithTimeInterval: method, I'm getting 
 unexpected timer firing times (20X faster than expected).
 
 ∙ If I specify 1.0 for the time interval, my method gets called 20 
 times/sec. 
 ∙ If I specify 20.0 for the time interval, my method gets called 1 
 time/sec.
 ∙ If I specify 100.0 for the time interval, my method gets called 5 
 times/sec.
 ...etc.
 
 Here is my only invocation, called once and nevermore:
 
 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];
>>> 
>>> Sounds like multiple timers are being installed. Set a breakpoint that logs 
>>> when hit.
>>> 
>> 
>> On break, It's always the same timer. This is with time interval set to 20.0:
>> 
>>   
>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:42 2020
>> . . .
>> 
> 
> I put a break directly after the creation of the timer, and introspection 
> already shows the wrong value for the time interval! And since .timeInterval 
> is a readonly attribute, I cannot force it to the correct value, nor is there 
> a -setTimeInterval: method.
> 
> Argh...
> -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/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: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Just ot be safe, reboot your Mac to make sure that things aren’t completely 
borked.  I’ve had to do this many times.  

> On Apr 29, 2020, at 4:26 PM, Carl Hoefs  
> wrote:
> 
> I accept that NSTimer works as documented! But I allege there must be 
> something odd about my (inherited) project that I can't quite put my finger 
> on.
> 
> Perhaps the +timerWithTimeInterval: method is overridden...
> -Carl
> 
> 
>> On Apr 29, 2020, at 2:15 PM, Alex Zavatone > > wrote:
>> 
>> I used your code in an iOS project and it works as expected.
>> 
>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>> 2020
>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>> 2020
>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>> 2020
>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>> 2020
>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>> 2020
>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>> 2020
>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>> 2020
>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>> 2020
>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>> 2020
>> 
>> I’ll mail you the project offlist.
>> 
>> 
>> 
>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
 
 On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com> 
 >> 
 wrote:
> 
> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> When I issue NSTimer's +timerWithTimeInterval: method, I'm getting 
>> unexpected timer firing times (20X faster than expected).
>> 
>> ∙ If I specify 1.0 for the time interval, my method gets called 20 
>> times/sec. 
>> ∙ If I specify 20.0 for the time interval, my method gets called 1 
>> time/sec.
>> ∙ If I specify 100.0 for the time interval, my method gets called 5 
>> times/sec.
>> ...etc.
>> 
>> Here is my only invocation, called once and nevermore:
>> 
>> 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];
> 
> Sounds like multiple timers are being installed. Set a breakpoint that 
> logs when hit.
> 
 
 On break, It's always the same timer. This is with time interval set to 
 20.0:
 
   
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:42 2020
 . . .
 
>>> 
>>> I put a break directly after the creation of the timer, and introspection 
>>> already shows the wrong value for the time interval! And since 
>>> .timeInterval is a readonly attribute, I cannot force it to the correct 
>>> value, nor is there a -setTimeInterval: method.
>>> 
>>> Argh...
>>> -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/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: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
For giggles, comment out the current code and replace it with exactly the same 
code.  Or put it in a new class and call the new class.



> On Apr 29, 2020, at 4:45 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> When everything goes wonky... it's time to reinstall all of Xcode...!
> 
> *sigh*
> -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/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: [OT] NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Sandor, it’s somewhere in the naming guide for the Objectice-C fundamental 
docs.  I could be confusing things though.

> On Apr 29, 2020, at 5:27 PM, Sandor Szatmari  
> wrote:
> 
> 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: Concurrent loading of images ?

2020-05-08 Thread Alex Zavatone via Cocoa-dev
iOS or MacOS?

> On May 8, 2020, at 11:53 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have kind of a slide-show app.
> 
> Sometimes, when it switches from one image to the next, there is a noticeable 
> lag when the file size of the next image is very big, say, 50 MB or more.
> Sometimes, it seems that loading the image takes 1-2 seconds.
> 
> So, I was thinking, maybe it helps to load the next image concurrently, while 
> the current one is still being displayed.
> 
> My question is: should I spawn a thread (using NSThreads' 
> detachNewThreadSelector), load the image in that thread, then exit the 
> thread? (no run loop)
> 
> Or should I use NSObject's performSelectorInBackground ?
> 
> 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.
> 
> What do you think?
> 
> 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/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: Minimizing my app kills timer ?

2020-05-08 Thread Alex Zavatone via Cocoa-dev
What if you spawned another process (NSTask?) from the screensaver and tested 
if a timer works in that?  It’s hokey as hell, but I use this approach to 
monitor a running process and do things when its state changes to suspended.

See if you can fire off a process and have a timer in it that logs the time and 
some string every 10 seconds.  Then minimize your screensaver and see what 
happens.

Various appendages crossed for you.  Sending thoughts and prayers.

Good luck.
Alex Zavatone

> On May 4, 2020, at 8:33 AM, Steve Mills via Cocoa-dev 
>  wrote:
> 
> On May 4, 2020, at 03:28:23, Gabriel Zachmann  wrote:
>> 
>> You mean, it could happen that Apple decides to make ScreenSaverView a 
>> subclass of some class other than NSView ? 
>> (currently, it is a subclass of NSView)
> 
> No, I mean just what I said. It's not guaranteed or even suggested that 
> ScreenSaverView be used with anything other than a screensaver.
> 
>> I agree that with Apple you never know what massive changes are waiting 
>> around the corner. But, are there other reasons why you recommend against 
>> using ScreenSaverView?
> 
> The screensaver animation in macOS is reliant on the engine that drives it. 
> Recently that changed from an older engine to what we can only guess is a 
> newer one, but some of them still run in what is known as a newly named 
> legacyScreenSaver, yet ScreenSaverEngine still fits in there somehow. We 
> don't know how it works and we don't *need* to know. Screensaver engines run 
> in a very controlled and limited environment. They need to be efficient. They 
> need to treat user input differently. They treat activation totally 
> differently. When you start trying to force such an engine to run in a normal 
> app that can deactivate, hide, minimize, etc, you're throwing it all kinds of 
> things it isn't designed to handle.
> 
> If you really want to run your screensaver animation in a non-screensaver 
> app, you'll need to control the animation, and rework your classes so you 
> have one class that is used by both the screensaver and your app, and do the 
> actual drawing in that class. It will be called by animateOneFrame in the 
> screensaver and by what animation engine you come up with in your app.
> 
> --
> 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/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: Minimizing my app kills timer ?

2020-05-08 Thread Alex Zavatone via Cocoa-dev
Oh Steve, which version of MacOS are you seeing this on?  

> On May 4, 2020, at 8:33 AM, Steve Mills via Cocoa-dev 
>  wrote:
> 
> On May 4, 2020, at 03:28:23, Gabriel Zachmann  wrote:
>> 
>> You mean, it could happen that Apple decides to make ScreenSaverView a 
>> subclass of some class other than NSView ? 
>> (currently, it is a subclass of NSView)
> 
> No, I mean just what I said. It's not guaranteed or even suggested that 
> ScreenSaverView be used with anything other than a screensaver.
> 
>> I agree that with Apple you never know what massive changes are waiting 
>> around the corner. But, are there other reasons why you recommend against 
>> using ScreenSaverView?
> 
> The screensaver animation in macOS is reliant on the engine that drives it. 
> Recently that changed from an older engine to what we can only guess is a 
> newer one, but some of them still run in what is known as a newly named 
> legacyScreenSaver, yet ScreenSaverEngine still fits in there somehow. We 
> don't know how it works and we don't *need* to know. Screensaver engines run 
> in a very controlled and limited environment. They need to be efficient. They 
> need to treat user input differently. They treat activation totally 
> differently. When you start trying to force such an engine to run in a normal 
> app that can deactivate, hide, minimize, etc, you're throwing it all kinds of 
> things it isn't designed to handle.
> 
> If you really want to run your screensaver animation in a non-screensaver 
> app, you'll need to control the animation, and rework your classes so you 
> have one class that is used by both the screensaver and your app, and do the 
> actual drawing in that class. It will be called by animateOneFrame in the 
> screensaver and by what animation engine you come up with in your app.
> 
> --
> 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/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: Concurrent loading of images ?

2020-05-08 Thread Alex Zavatone via Cocoa-dev

Does this seem related?

https://9to5mac.com/2020/04/28/new-bug-found-in-macos-can-quickly-fill-up-storage-when-importing-photos-with-image-capture/

"The problem discovered by the NeoFinder team is that the Mac adds 1.5MB of 
empty data to each converted photo, making the imported files larger for no 
reason. By looking inside these photos through a Hex-Editor, you can find a 
section full of zeroes, which results in unnecessarily larger files.”

I know you’re not capturing images, just loading them, but It’s pretty 
suspiciously similar.

> On May 8, 2020, at 11:53 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Sometimes, when it switches from one image to the next, there is a noticeable 
> lag when the file size of the next image is very big, say, 50 MB or more.


___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev
Using a queue is part of GCD.  You should probably not use the main queue since 
that is analogous to the main thread and the main thread is meant for updating 
the UI.

The good thing here is that you can sort of preload the next image in a queue 
after your last one has displayed. 

With a dispatchQueue, the idea here is that you have lots of tasks that you 
want to get done and you want the previous task to complete, then start the 
next one and so on and so on. You probably don’t need to do that for this 
application.

If I were doing this in Objective-C, I’d fire off a “preload” on an async 
dispatch to a block.  Something like this.

// create a queue to load the image
dispatch_group_t d_group = dispatch_group_create();
dispatch_queue_t bg_queue = 
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_group_async(d_group, bg_queue, ^{
NSLog(@“preloading");
Do that image loading here
});


If you did want to do something on the main queue, you can do it like this.

dispatch_async(dispatch_get_main_queue(), ^{
Do your main thread updates here
}

If you want to use a serial queue that doesn’t block the main thread you can do 
it like this.

// Dispatch the rest of session setup to the sessionQueue so that the main 
queue isn't blocked.
dispatch_queue_t sessionQueue = dispatch_queue_create("session queue", 
DISPATCH_QUEUE_SERIAL);
[self setSessionQueue:sessionQueue];

dispatch_async(sessionQueue, ^{
Do stuff here, but you want to read up on dipatch queues to see the 
best approach.
}


There’s lots of fun that you can have using these queues and GCD.  The trick is 
finding the approaches that suit your needs.

Hope these help.  

> On May 8, 2020, at 4:53 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
>>  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.
> 
> Thanks a lot for your response(s).
> 
> To me a queue suggests that you have lots and lots of tasks arriving from the 
> producer , which you need to buffer in queue, so that the consumer can work 
> on it one task at a time.
> 
> But in my case, I really have just one task, so the queue would - at most - 
> contain one task at a time.
> So, why not start the task right away using NSThread or NSOperation?
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Concurrent loading of images ?

2020-05-12 Thread Alex Zavatone via Cocoa-dev
Care to post a video on a Google drive so that we can see it?

One of my tricks (not just mine) is to have a 3 slots of for images, not just 
2.  When a new image loads, take the foreground one that is blended in to 100%, 
put an identical one ahead of it.  Make the changes to the new and old images 
behind it, then hide that foreground image.

You’re actually using a copy of the foreground image as a mask and you perform 
the swap behind it, then update the screen, then remove the top level one and 
refresh again. 

This is if I’m understanding what you’re going properly.

I’d expect that Apple’s video system to actually handle this if it still triple 
buffers, but it’s been 25 years since I read the docs on the Mac’s video 
subsystem.


In the mean time, add logging code that you can put breatpoints on and take a 
screen grab when you log.  That should help.

Cheers,
Alex Zavatone

> On May 12, 2020, at 3:27 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Thanks a million to everyone who has shared insights, hints, and advice on 
> this.
> 
> I have restructured my code, so now I do the heavy lifting of loading images 
> in a serial dispatch queue.
> However, there is still sometimes some stuttering visible in the animation of 
> the images.
> Does anyone have an idea what might be causing it?
> 
> Here is the current structure of my code, given in sort of a pseudo-code:
> 
> -animateOneframe:
>  // essentially, this gets called when the next image is to be displayed
>  current_image_ = prefetched_image_;  // these are CGImageRef's
>  dispatch_async( prefetch_queue_, ^{
>[self loadNextImage];
>  } );
>  create a new CALayer, 
>  assign the current_image_ as content, 
>  create an animation for the layer,
>  add the layer to the layer hierarchy
> 
> In -loadNextImage, I am doing all the heavy lifting of loading images
> (and the not-so-heavy), such as:
>  prefetched_image_ = nil;
>  CGImageSourceGetStatus
>  CGImageSourceCopyPropertiesAtIndex
>  CGImageSourceCreateThumbnailAtIndex
>  imageByApplyingOrientation
>  createCGImage
>  prefetched_image_ = new image
> 
> (I know there is some potential race condition here, but that is not of 
> concern to me right now.)
> 
> Overall, I get the impression that it is "better" (less stuttering),
> but sometimes there is still a stuttering in the animation when the app
> makes a transition from one image to the next one.
> 
> How could that be? 
> 
> Using Instruments, I can see this in the "heaviest stack trace" when CPU 
> usage is high in the main thread:
> 
>  41 CoreFoundation 3897.0  __CFRunLoopDoObservers
>  40 CoreFoundation 3897.0  
> __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
>  39 QuartzCore 3896.0  
> CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
>  38 QuartzCore 3896.0  CA::Transaction::commit()
>  37 QuartzCore 3895.0  CA::Context::commit_transaction(CA::Transaction*, 
> double)
>  36 QuartzCore 3895.0  CA::Layer::prepare_commit(CA::Transaction*)
>  35 QuartzCore 3895.0  CA::Render::prepare_image(CGImage*, CGColorSpace*, 
> unsigned int, double)
>  34 QuartzCore 3895.0  CA::Render::copy_image(CGImage*, CGColorSpace*, 
> unsigned int, double, double)
>  33 QuartzCore 3895.0  CA::Render::(anonymous 
> namespace)::create_image_by_rendering(CGImage*, CGColorSpace*, unsigned int, 
> double, CA::Render::ImageCopyType)
> 
> Are these functions the culprits? How can I make them get executed in the 
> background?
> 
> 
> All insights 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/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: Concurrent loading of images ?

2020-05-12 Thread Alex Zavatone via Cocoa-dev
Actually, can’t you disable screen updating while you’re swapping images?

> On May 12, 2020, at 3:35 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> Care to post a video on a Google drive so that we can see it?
> 
> One of my tricks (not just mine) is to have a 3 slots of for images, not just 
> 2.  When a new image loads, take the foreground one that is blended in to 
> 100%, put an identical one ahead of it.  Make the changes to the new and old 
> images behind it, then hide that foreground image.
> 
> You’re actually using a copy of the foreground image as a mask and you 
> perform the swap behind it, then update the screen, then remove the top level 
> one and refresh again. 
> 
> This is if I’m understanding what you’re going properly.
> 
> I’d expect that Apple’s video system to actually handle this if it still 
> triple buffers, but it’s been 25 years since I read the docs on the Mac’s 
> video subsystem.
> 
> 
> In the mean time, add logging code that you can put breatpoints on and take a 
> screen grab when you log.  That should help.
> 
> Cheers,
> Alex Zavatone
> 
>> On May 12, 2020, at 3:27 PM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> Thanks a million to everyone who has shared insights, hints, and advice on 
>> this.
>> 
>> I have restructured my code, so now I do the heavy lifting of loading images 
>> in a serial dispatch queue.
>> However, there is still sometimes some stuttering visible in the animation 
>> of the images.
>> Does anyone have an idea what might be causing it?
>> 
>> Here is the current structure of my code, given in sort of a pseudo-code:
>> 
>> -animateOneframe:
>> // essentially, this gets called when the next image is to be displayed
>> current_image_ = prefetched_image_;  // these are CGImageRef's
>> dispatch_async( prefetch_queue_, ^{
>>   [self loadNextImage];
>> } );
>> create a new CALayer, 
>> assign the current_image_ as content, 
>> create an animation for the layer,
>> add the layer to the layer hierarchy
>> 
>> In -loadNextImage, I am doing all the heavy lifting of loading images
>> (and the not-so-heavy), such as:
>> prefetched_image_ = nil;
>> CGImageSourceGetStatus
>> CGImageSourceCopyPropertiesAtIndex
>> CGImageSourceCreateThumbnailAtIndex
>> imageByApplyingOrientation
>> createCGImage
>> prefetched_image_ = new image
>> 
>> (I know there is some potential race condition here, but that is not of 
>> concern to me right now.)
>> 
>> Overall, I get the impression that it is "better" (less stuttering),
>> but sometimes there is still a stuttering in the animation when the app
>> makes a transition from one image to the next one.
>> 
>> How could that be? 
>> 
>> Using Instruments, I can see this in the "heaviest stack trace" when CPU 
>> usage is high in the main thread:
>> 
>> 41 CoreFoundation 3897.0  __CFRunLoopDoObservers
>> 40 CoreFoundation 3897.0  
>> __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
>> 39 QuartzCore 3896.0  
>> CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, 
>> void*)
>> 38 QuartzCore 3896.0  CA::Transaction::commit()
>> 37 QuartzCore 3895.0  CA::Context::commit_transaction(CA::Transaction*, 
>> double)
>> 36 QuartzCore 3895.0  CA::Layer::prepare_commit(CA::Transaction*)
>> 35 QuartzCore 3895.0  CA::Render::prepare_image(CGImage*, CGColorSpace*, 
>> unsigned int, double)
>> 34 QuartzCore 3895.0  CA::Render::copy_image(CGImage*, CGColorSpace*, 
>> unsigned int, double, double)
>> 33 QuartzCore 3895.0  CA::Render::(anonymous 
>> namespace)::create_image_by_rendering(CGImage*, CGColorSpace*, unsigned int, 
>> double, CA::Render::ImageCopyType)
>> 
>> Are these functions the culprits? How can I make them get executed in the 
>> background?
>> 
>> 
>> All insights 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/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin r

Re: Concurrent loading of images ?

2020-05-13 Thread Alex Zavatone via Cocoa-dev
Ahh, there’s a jitter when moving.

Try creating an async dispatch to a background thread in a block.



> On May 13, 2020, at 3:34 PM, Gabriel Zachmann  wrote:
> 
>> 
>> Care to post a video on a Google drive so that we can see it?
> 
> Good idea - here is the video:
> 
>  https://owncloud.informatik.uni-bremen.de/index.php/s/TTGG6bKCMFLqY4g
> 
> (encoded in H265/HEVC for saving file size)
> 
> I think, you can see clearly the stuttering. Sometimes it is more subtle, 
> sometimes, the stuttering pauses the animation for a second.
> Sometimes, it occurs when the background thread is prefetching the next image 
> (usually happens directly after the switch to a new image), sometimes, it 
> happens when the new image is beginning to show (i.e., when it's CALayer is 
> added to the layer hierarchy).
> 
> I made another experiment, which puzzles me even more.
> I am storing a history of the CGImageRef's that had been displayed so far.
> When I go back through that history, I use those stored CGImageRef's to 
> create new CALayers which I then add to the layer hierarchy (the image that 
> had been shown until then is just removed from the layer hierarchy, or rather 
> its CALayer).
> The funny thing is that when I do that (using older CGImageRef's) the switch 
> from one image to the next one is instantaneous and there is no stuttering at 
> all.
> 
> You can see that in the video starting at 1:19.
> 
> It seems as if some more processing is going on when a CGImage is assigned to 
> a CALayer,
> which CGImageSourceCreateThumbnailAtIndex() and all the other functions I 
> listed below do not do.
> Or it happens at the point when an animation is added.
> And the result of that is stored inside the CGImage!
> But how can I force that in the background thread?
> (without making the animation of the foreground thread stutter.)
> 
> I made another little experiment.
> I keep (kinetically) scrolling through the source code in Xcode with high 
> velocity while my app is running in the foreground.
> And when it switches images there is sometimes even a stuttering in that 
> scrolling.
> 
>> 
>> One of my tricks (not just mine) is to have a 3 slots of for images, not 
>> just 2.  When a new image loads, take the foreground one that is blended in 
>> to 100%, put an identical one ahead of it.  Make the changes to the new and 
>> old images behind it, then hide that foreground image.
> 
> Sorry, I didn't get how that would work with my animations.
> Maybe, you can describe it again once you've seen the video.
> 
> 
> 
> Best, Gab.
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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-13 Thread Alex Zavatone via Cocoa-dev
One cheap option would be to ease the sliding in to a stop position and have a 
nice little pause where you swap images.  Of course, that’s cheating.



> On May 13, 2020, at 3:34 PM, Gabriel Zachmann  wrote:
> 
>> 
>> Care to post a video on a Google drive so that we can see it?
> 
> Good idea - here is the video:
> 
>  https://owncloud.informatik.uni-bremen.de/index.php/s/TTGG6bKCMFLqY4g
> 
> (encoded in H265/HEVC for saving file size)
> 
> I think, you can see clearly the stuttering. Sometimes it is more subtle, 
> sometimes, the stuttering pauses the animation for a second.
> Sometimes, it occurs when the background thread is prefetching the next image 
> (usually happens directly after the switch to a new image), sometimes, it 
> happens when the new image is beginning to show (i.e., when it's CALayer is 
> added to the layer hierarchy).
> 
> I made another experiment, which puzzles me even more.
> I am storing a history of the CGImageRef's that had been displayed so far.
> When I go back through that history, I use those stored CGImageRef's to 
> create new CALayers which I then add to the layer hierarchy (the image that 
> had been shown until then is just removed from the layer hierarchy, or rather 
> its CALayer).
> The funny thing is that when I do that (using older CGImageRef's) the switch 
> from one image to the next one is instantaneous and there is no stuttering at 
> all.
> 
> You can see that in the video starting at 1:19.
> 
> It seems as if some more processing is going on when a CGImage is assigned to 
> a CALayer,
> which CGImageSourceCreateThumbnailAtIndex() and all the other functions I 
> listed below do not do.
> Or it happens at the point when an animation is added.
> And the result of that is stored inside the CGImage!
> But how can I force that in the background thread?
> (without making the animation of the foreground thread stutter.)
> 
> I made another little experiment.
> I keep (kinetically) scrolling through the source code in Xcode with high 
> velocity while my app is running in the foreground.
> And when it switches images there is sometimes even a stuttering in that 
> scrolling.
> 
>> 
>> One of my tricks (not just mine) is to have a 3 slots of for images, not 
>> just 2.  When a new image loads, take the foreground one that is blended in 
>> to 100%, put an identical one ahead of it.  Make the changes to the new and 
>> old images behind it, then hide that foreground image.
> 
> Sorry, I didn't get how that would work with my animations.
> Maybe, you can describe it again once you've seen the video.
> 
> 
> 
> Best, Gab.
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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-15 Thread Alex Zavatone via Cocoa-dev
There are two more of these groups created Jens that you may find helpful.

xc...@apple-dev.groups.io
co...@apple-dev.groups.io




> On May 15, 2020, at 2:18 PM, Richard Charles via Cocoa-dev 
>  wrote:
> 
> Thanks to everyone for your comments and suggestions.
> 
> I now have my app with embedded frameworks working as multiple individual 
> projects or combined into a single workspace. It all works in Xcode 9 or 11 
> and archiving also works. The app was successfully notarized by Apple.
> 
> There is actually an informative technical note on the subject.
> 
> https://developer.apple.com/library/archive/technotes/tn2435/_index.html
> 
> I appreciate the list responding to an Xcode question. The xcode-users list 
> has been shut down and I have yet to acquire a taste for the new apple-dev 
> groups.
> 
> Thanks again.
> 
> --Richard Charles
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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: Finding memory leaks

2020-05-20 Thread Alex Zavatone via Cocoa-dev
Do NOT use Instruments.  

Use the Memory Graph Debugger.  It’s in your debugger console near the 
breakpoint button and View Hierarchy Debugger.

Try that first.  

> On May 20, 2020, at 9:03 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have a few stupid questions regarding (potential) memory leaks,
> so please bear with me.
> First of all, my code is ARC managed.
> 
> I tried the Leaks tool of Instruments.
> 
> It tells me, if i understand correctly, that I have a leak at this line of my 
> code:
> 
>CFDictionaryRef fileProps = CGImageSourceCopyPropertiesAtIndex( new_image, 
> 0, NULL ); 
> 
> This line is in a method I declared like that:
> 
> - (void) loadNextImageWithIndex: (unsigned long) next_index image: 
> (CGImageRef *) next_image
>  withProps: (CFDictionaryRef *) next_props
> 
> and at the end of the function, I pass fileProps back like so
> 
>   *next_props = fileProps;
> 
> The caller then makes a copy of next_props for later use, and CFRelease's 
> next_props.
> (That copy is also released later.)
> 
> So it is unclear to me why the Leaks tool thinks that the above line leaks 
> memory.
> 
> 
> 
> Another area of questions is around CALayer's and images.
> I create images like so:
> 
>CGImageRef newImageRef = CGImageSourceCreateThumbnailAtIndex( new_image, 0,
>   (__bridge 
> CFDictionaryRef) imageOpts );
> I store newImageRef in an array (history_of_images).
> Then, I assign newImageRef to a CALayer like this:
> 
>imgLayer.contents = (__bridge id)(newImageRef);
> 
> At some point later, when the layer is no longer part of the layer hierarchy, 
> I release it like this:
> 
>   CGImageRelease( history_of_images[k].img );
> 
> Can you spot any point in this sequence where there could be a memory leak?
> Does any of the assignments I described create a copy?
> Should I release CALayer's myself after I have removed it from its super 
> layer?
> By the growth of the memory usage of my app I suspect that the images I've 
> been loading keep lingering on somewhere in memory.
> 
> 
> Another area of questions centers around dispatch queues.
> The above stuff (loading, thumbnail creation) is, mostly, done in a 
> background thread via dispatch_async.
> I have tried to put an @autoreleasepool around the code that runs in the 
> background thread, to no avail.
> (My code is under ARC.)
> 
> But in Instruments, all indications (e.g., Heaviest stack trace) point to 
> CGImageSourceCreateThumbnailAtIndex, that shows a stack trace like that:
> 
>  13 libdispatch.dylib  269.42 KB _dispatch_client_callout
>  12 ArtSaverApp  269.42 KB -[ArtSaverView loadNextImage] 
> /Users/zach/Code/ArtSaver/ArtSaverView.m:2045
>  11 ArtSaverApp  269.42 KB -[ArtSaverView 
> loadNextImageWithIndex:image:withProps:] 
> /Users/zach/Code/ArtSaver/ArtSaverView.m:2083
>  10 ImageIO  248.44 KB CGImageSourceCopyPropertiesAtIndex
>   9 ImageIO  248.44 KB IIOImageSource::copyPropertiesAtIndex(unsigned 
> long, IIODictionary*)
>   8 ImageIO  248.30 KB 
> IIOImageSource::getPropertiesAtIndexInternal(unsigned long, IIODictionary*)
>   7 ImageIO  244.78 KB IIOImageSource::makeImagePlus(unsigned long, 
> IIODictionary*)
>   6 ImageIO  100.08 KB 
> IIO_Reader_AppleJPEG::initImageAtOffset(CGImagePlugin*, unsigned long, 
> unsigned long, unsigned long)
>   5 ImageIO   97.58 KB IIOReadPlugin::callInitialize()
>   4 ImageIO   93.64 KB AppleJPEGReadPlugin::initialize(IIODictionary*)
>   3 ImageIO   52.00 KB AppleJPEGReadPlugin::appleJPEGDecodeSetup()
>   2 AppleJPEG   52.00 KB applejpeg_decode_create
>   1 libsystem_malloc.dylib   52.00 KB malloc
>   0 libsystem_malloc.dylib   52.00 KB malloc_zone_malloc
> 
> (ArtSaverApp is, of course, my code.)
> Similar backtraces show up when I click on the various Malloc leaks in the 
> Leaks by Backtrace view.
> Almost all of them go through CGImageSourceCopyPropertiesAtIndex(), and the 
> responsible library is 
> ImageIO.
> 
> 
> Thanks a lot in advance for all kinds of insights and hints.
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Finding memory leaks

2020-05-20 Thread Alex Zavatone via Cocoa-dev
Also, in your run scheme, enable the Diagnostics for Logging > Malloc Stack > 
Live Allocations Only.

> On May 20, 2020, at 10:08 AM, Georg Seifert via Cocoa-dev 
>  wrote:
> 
> You need to check the backtrace where the leaking object was created. 
> Sometimes it points to a line that has nothing to do with the leak, it is 
> just triggering it.
> 
> g
> 
>> On 20.05.2020, at 16:03, Gabriel Zachmann via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> I have a few stupid questions regarding (potential) memory leaks,
>> so please bear with me.
>> First of all, my code is ARC managed.
>> 
>> I tried the Leaks tool of Instruments.
>> 
>> It tells me, if i understand correctly, that I have a leak at this line of 
>> my code:
>> 
>>   CFDictionaryRef fileProps = CGImageSourceCopyPropertiesAtIndex( new_image, 
>> 0, NULL ); 
>> 
>> This line is in a method I declared like that:
>> 
>> - (void) loadNextImageWithIndex: (unsigned long) next_index image: 
>> (CGImageRef *) next_image
>> withProps: (CFDictionaryRef *) next_props
>> 
>> and at the end of the function, I pass fileProps back like so
>> 
>>  *next_props = fileProps;
>> 
>> The caller then makes a copy of next_props for later use, and CFRelease's 
>> next_props.
>> (That copy is also released later.)
>> 
>> So it is unclear to me why the Leaks tool thinks that the above line leaks 
>> memory.
>> 
>> 
>> 
>> Another area of questions is around CALayer's and images.
>> I create images like so:
>> 
>>   CGImageRef newImageRef = CGImageSourceCreateThumbnailAtIndex( new_image, 0,
>>  (__bridge 
>> CFDictionaryRef) imageOpts );
>> I store newImageRef in an array (history_of_images).
>> Then, I assign newImageRef to a CALayer like this:
>> 
>>   imgLayer.contents = (__bridge id)(newImageRef);
>> 
>> At some point later, when the layer is no longer part of the layer 
>> hierarchy, I release it like this:
>> 
>>  CGImageRelease( history_of_images[k].img );
>> 
>> Can you spot any point in this sequence where there could be a memory leak?
>> Does any of the assignments I described create a copy?
>> Should I release CALayer's myself after I have removed it from its super 
>> layer?
>> By the growth of the memory usage of my app I suspect that the images I've 
>> been loading keep lingering on somewhere in memory.
>> 
>> 
>> Another area of questions centers around dispatch queues.
>> The above stuff (loading, thumbnail creation) is, mostly, done in a 
>> background thread via dispatch_async.
>> I have tried to put an @autoreleasepool around the code that runs in the 
>> background thread, to no avail.
>> (My code is under ARC.)
>> 
>> But in Instruments, all indications (e.g., Heaviest stack trace) point to 
>> CGImageSourceCreateThumbnailAtIndex, that shows a stack trace like that:
>> 
>> 13 libdispatch.dylib  269.42 KB _dispatch_client_callout
>> 12 ArtSaverApp  269.42 KB -[ArtSaverView loadNextImage] 
>> /Users/zach/Code/ArtSaver/ArtSaverView.m:2045
>> 11 ArtSaverApp  269.42 KB -[ArtSaverView 
>> loadNextImageWithIndex:image:withProps:] 
>> /Users/zach/Code/ArtSaver/ArtSaverView.m:2083
>> 10 ImageIO  248.44 KB CGImageSourceCopyPropertiesAtIndex
>>  9 ImageIO  248.44 KB IIOImageSource::copyPropertiesAtIndex(unsigned 
>> long, IIODictionary*)
>>  8 ImageIO  248.30 KB 
>> IIOImageSource::getPropertiesAtIndexInternal(unsigned long, IIODictionary*)
>>  7 ImageIO  244.78 KB IIOImageSource::makeImagePlus(unsigned long, 
>> IIODictionary*)
>>  6 ImageIO  100.08 KB 
>> IIO_Reader_AppleJPEG::initImageAtOffset(CGImagePlugin*, unsigned long, 
>> unsigned long, unsigned long)
>>  5 ImageIO   97.58 KB IIOReadPlugin::callInitialize()
>>  4 ImageIO   93.64 KB AppleJPEGReadPlugin::initialize(IIODictionary*)
>>  3 ImageIO   52.00 KB AppleJPEGReadPlugin::appleJPEGDecodeSetup()
>>  2 AppleJPEG   52.00 KB applejpeg_decode_create
>>  1 libsystem_malloc.dylib   52.00 KB malloc
>>  0 libsystem_malloc.dylib   52.00 KB malloc_zone_malloc
>> 
>> (ArtSaverApp is, of course, my code.)
>> Similar backtraces show up when I click on the various Malloc leaks in the 
>> Leaks by Backtrace view.
>> Almost all of them go through CGImageSourceCopyPropertiesAtIndex(), and the 
>> responsible library is 
>> ImageIO.
>> 
>> 
>> Thanks a lot in advance for all kinds of insights and hints.
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/georg.seifert%40gmx.de 
>> 
>> 
>> This email sent to georg.seif...@gmx.de 
> 
> 

Re: Finding memory leaks

2020-05-20 Thread Alex Zavatone via Cocoa-dev
For iOS, I’ve found that setting up a test to replicate the memory leak, or 
simply running tests is a great idea.  Here’s where Instruments sucks.  Running 
on the Simulator, Instruments often drops the connection to the target.  Also, 
I’ve gotten Instruments files that are 30 GB, while just setting a breakpoint 
in a test and invoking the memory graph debugger lets you see the relationship 
between objects and save a .memgraph document so that you can open it again.

Here are some of the horror stories caused by my former team.

We had 1400 of them.

https://imgur.com/Pq0eEkf <https://imgur.com/Pq0eEkf>
https://imgur.com/mavOyOT <https://imgur.com/mavOyOT>
https://imgur.com/3mnRUa1 <https://imgur.com/3mnRUa1>
https://imgur.com/4nksFco

So much easier than walking the stack backtrace, but when you enable logging in 
the scheme Diagnostics, you also have your stack backtrace, so you can see 
where objects have multiple references causing the retain cycles and examine 
the backtrace if you want to.

Simply select the object and the backtrace is in the right Inspector pane.

- Alex Zavatone

> On May 20, 2020, at 2:58 PM, Rob Petrovec  wrote:
> 
> I’ve had a lot of success with Instruments leaks traces.  In the 
> retain/release world we live in, knowing the backtrace to where the object 
> was created isn’t enough.  Instruments gives a nice UI to walk the 
> retain/release history of an object, and the backtrace of each 
> retain/autorelease/release.  Using a memgraph as Alex suggested is also good, 
> but can sometimes be hard to parse when the map is HUGE!  Either way, both 
> Instruments and memgraphs are tools you should definitely learn & use.
> 
> My only real gripe is that both Instruments & memgraphs don’t handle C++ 
> objects very well.  It would be nice if they understood shared_ptr & 
> unique_ptr.
> 
> —Rob
> 
> 
>> On May 20, 2020, at 9:16 AM, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> Also, in your run scheme, enable the Diagnostics for Logging > Malloc Stack 
>> > Live Allocations Only.
>> 
>>> On May 20, 2020, at 10:08 AM, Georg Seifert via Cocoa-dev 
>>>  wrote:
>>> 
>>> You need to check the backtrace where the leaking object was created. 
>>> Sometimes it points to a line that has nothing to do with the leak, it is 
>>> just triggering it.
>>> 
>>> g
>>> 
>>>> On 20.05.2020, at 16:03, Gabriel Zachmann via Cocoa-dev 
>>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>>> 
>>>> I have a few stupid questions regarding (potential) memory leaks,
>>>> so please bear with me.
>>>> First of all, my code is ARC managed.
>>>> 
>>>> I tried the Leaks tool of Instruments.
>>>> 
>>>> It tells me, if i understand correctly, that I have a leak at this line of 
>>>> my code:
>>>> 
>>>> CFDictionaryRef fileProps = CGImageSourceCopyPropertiesAtIndex( new_image, 
>>>> 0, NULL ); 
>>>> 
>>>> This line is in a method I declared like that:
>>>> 
>>>> - (void) loadNextImageWithIndex: (unsigned long) next_index image: 
>>>> (CGImageRef *) next_image
>>>>   withProps: (CFDictionaryRef *) next_props
>>>> 
>>>> and at the end of the function, I pass fileProps back like so
>>>> 
>>>> *next_props = fileProps;
>>>> 
>>>> The caller then makes a copy of next_props for later use, and CFRelease's 
>>>> next_props.
>>>> (That copy is also released later.)
>>>> 
>>>> So it is unclear to me why the Leaks tool thinks that the above line leaks 
>>>> memory.
>>>> 
>>>> 
>>>> 
>>>> Another area of questions is around CALayer's and images.
>>>> I create images like so:
>>>> 
>>>> CGImageRef newImageRef = CGImageSourceCreateThumbnailAtIndex( new_image, 0,
>>>>(__bridge 
>>>> CFDictionaryRef) imageOpts );
>>>> I store newImageRef in an array (history_of_images).
>>>> Then, I assign newImageRef to a CALayer like this:
>>>> 
>>>> imgLayer.contents = (__bridge id)(newImageRef);
>>>> 
>>>> At some point later, when the layer is no longer part of the layer 
>>>> hierarchy, I release it like this:
>>>> 
>>>> CGImageRelease( history_of_images[k].img );
>>>> 
>>>> Can you spot any point in this sequence where there could be a memory leak?

Re: Xcode Archive builds Debug version?

2020-05-25 Thread Alex Zavatone via Cocoa-dev
It’s set in your schemes.  Pick your Release configuration.

> On May 24, 2020, at 4:54 AM, Sandor Szatmari via Cocoa-dev 
>  wrote:
> 
> 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/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: Relieving memory pressure

2020-06-08 Thread Alex Zavatone via Cocoa-dev


> On Jun 7, 2020, at 3:15 PM, Steve Christensen via Cocoa-dev 
>  wrote:
> 
> For slide shows that I’ve seen, they typically display each image for several 
> seconds at a time. If that’s the case, why can’t you just load the next image 
> from disk on a background queue while the current image is being displayed 
> and not have to worry about memory usage needed to cache multiple images? (I 
> am assuming that you’ll need to load each image once anyway.)

Yeah, that’s like the preloading I suggested on an earlier thread about loading 
screensaver images.  Then after an image has transitioned out of display, you 
can nil all references to it.  If you know the order of when images will be 
displayed and removed, you can even create a mechanism for loading what’s to 
come and removing what has disappeared.  Pre-calculate your display array, 
unload everything you don’t need anymore and preload everything that will be 
displayed next.  Just make sure you don’t unload anything that is used in the 
current or next display.

You’d have a previous list of images, a current list of images and a next list 
of images.

Just do some set operations to make sure you’re not unloading and loading the 
same image.  

For unloading, I’m referring to making the image reference count 0 and then 
nilling variables.  

So, you’d have this mechanism rolling along on a thread while you have another 
process for the display of the images.

How does that sound?  

> If caching is required—apologies if I missed the “why” in earlier 
> comments—then have you looked at NSCache? From the docs:
> 
> The NSCache class incorporates various auto-eviction policies, which ensure 
> that a cache doesn’t use too much of the system’s memory. If memory is needed 
> by other applications, these policies remove some items from the cache, 
> minimizing its memory footprint.
> 
> 
>> On Jun 7, 2020, at 5:31 AM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> Good question.
>> 
>> Well, some users want to feed my app with image files of 100 MB, even up to 
>> 400 MB (mostly jpeg compressed).
>> Those images have resolutions of over 8k, sometimes over 10k.
>> 
>> The slideshow app needs to be able to zoom into those images with at least a 
>> factor 2x scaling.
>> 
>> So I figured that if someone has a 4k monitor, creating thumbnails with 8k 
>> resolution maximum should be sufficient.
>> 
>> An 8k x 8k image needs at least 200 MB (1 byte per channel).
>> I don't know how CGImage stores the uncompressed images internally,
>> but my experience seems to indicate that it uses significantly more memory 
>> than that.
>> (maybe it uses two bytes per channel, or even floats, or there is some other 
>> aux data)
>> 
>>> What do you need a 1GB thumbnail for? There is no screen that can display 
>>> that. For a slideshow app you could scale your thumbnails at creation time 
>>> to the users biggest screen pixel size, don’t you think?
>>> 
>>> Christos Konidaris
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Points vs pixels in a bash script

2020-06-09 Thread Alex Zavatone via Cocoa-dev
Don’t you need to find out what the pixels per inch of the display is first?  
At 72 dpi or ppi, a pixel = a point.  

Can you get that info first?  

> On Jun 8, 2020, at 4:43 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I know this mailing list might not be the perfect fit for my question,
> but maybe someone has an idea.
> 
> I have a problem converting points (I think) to pixels in a bash script.
> I'd rather not write an extra C/Cocoa utility for that.
> 
> Using
>   system_profiler SPDisplaysDataType
> I can retrieve the size of a Mac's display in pixels. 
> 
> However, the command
> 
>   tell application "System Events" to get the size of every window of every 
> process
> 
> (which I execute from my bash script using osascript) apparently does NOT 
> return window sizes in pixels. I guess it's the strange "Apple points" units. 
> According to my experiments, on my MacBook Pro Retina, for instance, a 
> fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.
> By contrast, system_profiler reports 2880 x 1800.
> 
> So, the question is: how can I determine the screen size of a Mac from my 
> bash script in the same units like "System Events" uses? 
> Or, how can I determine the factor by which I have to convert pixels into 
> those other units?
> 
> 
> Many thanks in advance for any insights or hints.
> 
> 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/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: Launching another app from mine

2020-06-15 Thread Alex Zavatone via Cocoa-dev
Mac, iOS, WatchOS, iPadOS?  TRS-80 Basic?  Which platform?

> On Jun 15, 2020, at 1:30 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I would like to launch application B from my application A using Swift.
> Both applications are created, compiled, signed, and notarized by me.
> Challenge: no user intervention should be necessary when launching B from A.
> 
> 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/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: Updating localised auth-prompt strings

2020-06-15 Thread Alex Zavatone via Cocoa-dev
Platform?

> On Jun 15, 2020, at 9:51 AM, Mark Allan via Cocoa-dev 
>  wrote:
> 
> Hi folks, 
> 
> I have an app which communicates with a privileged helper tool, and I used 
> the AuthorizationRightSet API to add the rights, requirements, and prompt 
> strings to the authorizationdb - as per Apple's documentation. As expected, 
> this initial call to "AuthorizationRightSet" does not prompt for 
> authentication to add the rights to the DB.
> 
> Some of my app's functions require presenting an authentication prompt to the 
> user, and these prompts have been localised.
> 
> Calling 'sudo security authorizationdb read' in the Terminal shows the rule, 
> the default prompt, and all the localised versions of the prompt string.
> 
> All fine so far, but I've recently reworded some of the authentication prompt 
> strings, so it (and all the localisations) now need to be updated.
> 
> How do I do this? Naively I thought I could just update the respective 
> localizable.strings file, and it would just work, but as the translated text 
> is hard-coded into the authorizationdb, this doesn't seem possible.
> 
> Using AuthorizationRightSet again will cause an authentication prompt to 
> appear as soon as my app is launched. As does AuthorizationRightRemove.
> 
> Now, I know I could remove all my rights from the authorizationdb by calling 
> "sudo security authorizationdb remove XYZ" for each of my app's rights, but I 
> obviously can't expect users to do this. Neither do I want them to be 
> presented with an auth prompt purely to update some strings.
> 
> I could also just change the auth right name so that the app proceeds as if 
> that particular right had never been in the database in the first place, but 
> that seems like a nasty hacky way to do it.
> 
> so, where does this leave me? I can't be the only person who's come up 
> against this issue, but web searches and StackOverflow aren't giving me much 
> to go on.
> 
> Many thanks
> Mark
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Launching another app from mine

2020-06-16 Thread Alex Zavatone via Cocoa-dev
While I agree with the URL scheme launching approach, I’ve seem to remember 
using NSTask to run a shell script.  It would be interesting to see how that 
works.  

In Xcode prebuild scripts, I launch a shell script that gets the app PID and 
launches other apps or scripts based on the app PID state to help debug memory 
leaks.  It feels hacky, but I’d be interested in seeing if that works.

In a MacOS app, I can use NSTask if I remember correctly, but that approach 
doesn’t work in iOS.

Let us know how it goes.

> On Jun 16, 2020, at 2:05 PM, Gabriel Zachmann  wrote:
> 
> Sorry, macOS.
> 
> Best regards, Gabriel
> 
>> Mac, iOS, WatchOS, iPadOS?  TRS-80 Basic?  Which platform?
>> 
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev
Symbolic breakpoints, my man!



> On Jun 24, 2020, at 11:57 AM, 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 ..
> 
> 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/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: Images in UI in dark mode

2020-07-24 Thread Alex Zavatone via Cocoa-dev
Have you looked at it in a view debugger?  Is this a Mac app, an iOS app or 
what?  Which version of Xcode are you using?

> On Jul 24, 2020, at 11:22 AM, David Durkee via Cocoa-dev 
>  wrote:
> 
> I am finally updating my application to support dark mode. I’ve run into a 
> hitch in a place where I use images in buttons or other controls. I formerly 
> put the name of the png image in the image field of the control or segment in 
> question. I updated for dark mode by creating new images for dark mode, 
> creating image sets in an asset catalog, including both light and dark mode 
> versions of the images in the image set, and repointing the controls or 
> segments to the new image sets (which uses different names from the original 
> images). 
> 
> This looks right in the xib window in Xcode when I switch between light mode 
> and dark mode display. But when I build and run the program, I am only seeing 
> the light mode versions of the images used even when I am in dark mode. I 
> have verified that it is using the image sets by changing the images in the 
> light mode slots, but it is never using the dark mode versions from those 
> sets.
> 
> All other controls in the view are respecting light mode and dark mode 
> changes. The chrome of the control that contains the image is also changing 
> correctly.
> 
> I have also created new controls in the xib or different types and they 
> behave the same way.
> 
> 
> Any idea what I'm doing wrong?
> 
> David
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Funny issue: one line in GUI is grey-ish

2020-08-09 Thread Alex Zavatone via Cocoa-dev
What are the forecolor and alpha values?  Of the text and of the label?  Try 
changing the color to something else and if it’s also lighter, then somewhere 
you have a 50% alpha value.

> On Aug 9, 2020, at 7:58 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I have a simple app (status bar item) with a simple GUI.
> The funny thing is that one text line in the GUI is grey-ish,
> but NOT in the XIB in XCode ... and I can't determine why that is or how to 
> correct it.
> (It has the font "System Regular".)
> 
> If you want to see it for yourself, here is a screenshot of the GUI:
> 
> https://owncloud.informatik.uni-bremen.de/index.php/s/B6X4YR9YkmSbmGW
> 
> If you want to check the source code:
> 
> https://owncloud.informatik.uni-bremen.de/index.php/s/9aa4XmPJRQ2sJT5
> 
> 
> 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/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: Funny issue: one line in GUI is grey-ish

2020-08-09 Thread Alex Zavatone via Cocoa-dev
Do you have a view hierarchy inspector so that you can see each of the layers?

If you change the color to red, does it appear pink?  If it does, one of the 
layers in the view hierarchy is at a < 1.0 alpha.


> On Aug 9, 2020, at 8:48 AM, Gabriel Zachmann  wrote:
> 
> Thanks a lot for the quick response.
> 
> Alpha = 1
> 
> Don't know about forecolor - with NSButton , I don't seem to get a "Text 
> Color" in Xcode's XIB controls.
> 
> Best regards, Gabriel
> 
> 
>> On 9. Aug 2020, at 16:39, Alex Zavatone  wrote:
>> 
>> What are the forecolor and alpha values?  Of the text and of the label?  Try 
>> changing the color to something else and if it’s also lighter, then 
>> somewhere you have a 50% alpha value.
>> 
>>> On Aug 9, 2020, at 7:58 AM, Gabriel Zachmann via Cocoa-dev 
>>>  wrote:
>>> 
>>> I have a simple app (status bar item) with a simple GUI.
>>> The funny thing is that one text line in the GUI is grey-ish,
>>> but NOT in the XIB in XCode ... and I can't determine why that is or how to 
>>> correct it.
>>> (It has the font "System Regular".)
>>> 
>>> If you want to see it for yourself, here is a screenshot of the GUI:
>>> 
>>> https://owncloud.informatik.uni-bremen.de/index.php/s/B6X4YR9YkmSbmGW
>>> 
>>> If you want to check the source code:
>>> 
>>> https://owncloud.informatik.uni-bremen.de/index.php/s/9aa4XmPJRQ2sJT5
>>> 
>>> 
>>> 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/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: Question about Info.plists

2020-08-19 Thread Alex Zavatone via Cocoa-dev
I have build scripts that do that based on the # of the git checkins.

I’ll send you the projects.


> On Aug 19, 2020, at 11:07 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Question:
> 
> Is there a way to use a key/value that was defined earlier in the plist file
> to define a value for a later key?
> 
> Explanation:
> I have a macOS project with an automatically created "About" window.
> The plist file has, additionally to all the default stuff, the key 
> CFBuildNumber (with a value that I increment automatically).
> 
> In Xcode, I tried to change "Bundle version" to a value like
> 
>   $(CURRENT_PROJECT_VERSION)_$(CFBuildNumber)
> 
> However, in the final Info.plist in the app's bundle, this then looks like
> 
>CFBundleVersion
>3.1_
> 
> Notice the underscore, but the value of CFBuildNumber is gone.
> "3.1", BTW, is the value I have set under
> 
>Project / Targets / General / Identity / Build
> 
> I have tried to change parentheses into curly braces, to no avail.
> 
> So, question again: is there a way to use a key/value that was defined 
> earlier in the plist file
> to define a value for a later key?
> I'd like to do that so that the "About" window contains the build number, too.
> 
> 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/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: Question about Info.plists

2020-08-19 Thread Alex Zavatone via Cocoa-dev
Here’s the info from my StackOverflow answer.

https://stackoverflow.com/a/55525399/1058199

Over the years, Apple has come up with several manners of changing version and 
build numbers. Many of them are now outdated and poor practice. Changing 
CURRENT_PROJECT_VERSION modifies values within your project's project.pbxproj 
file and if you are running a distributed team, this will cause merge conflicts 
if the other half of the team tries to update and while they were asleep, you 
updated this internal value. If you are using pods, you'll get several more 
merge conflicts per pod that you add to the project. 

So, CURRENT_PROJECT_VERSION?

Don't use it.

Within the info.plist file are these keys. 

CFBundleVersion
CFBundleShortVersionString
Use CFBundleVersion for your app's build number. Use CFBundleShortVersionString 
for your app's version number. 

Use Plistbuddy to do it. 

CFBundleShortVersionString
3.0.7
CFBundleVersion
934


Try the script below.

#!/bin/sh

# To make executable, use: chmod u+x 
Build-Versioning-Scripts/Increment_Build_Number.sh
# to locate your target's info.plist use
# ${PRODUCT_SETTINGS_PATH}

echo ""
echo "Info.plist for target: ${PRODUCT_SETTINGS_PATH}"

buildNum=$(/usr/libexec/Plistbuddy -c "Print CFBundleVersion" 
"${PRODUCT_SETTINGS_PATH}")
echo "Current build #: $buildNum"

if [ -z "$buildNum" ]; then
echo "No build number found in $PRODUCT_SETTINGS_PATH"
exit 2
fi

buildNum=$(expr $buildNum + 1)
echo "Build # incremented to: $buildNum"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNum" 
"$PRODUCT_SETTINGS_PATH"
echo ""
exit 0
By adding this script to your build or archive process on your build machine, 
this will automatically update the app's build number. If you wish to increment 
your app's versionnumber, change CFBundleShortVersionString (Bundle versions 
string, short) in the info.plist manually. 


> On Aug 19, 2020, at 3:07 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> I have build scripts that do that based on the # of the git checkins.
> 
> I’ll send you the projects.
> 
> 
>> On Aug 19, 2020, at 11:07 AM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> Question:
>> 
>> Is there a way to use a key/value that was defined earlier in the plist file
>> to define a value for a later key?
>> 
>> Explanation:
>> I have a macOS project with an automatically created "About" window.
>> The plist file has, additionally to all the default stuff, the key 
>> CFBuildNumber (with a value that I increment automatically).
>> 
>> In Xcode, I tried to change "Bundle version" to a value like
>> 
>>  $(CURRENT_PROJECT_VERSION)_$(CFBuildNumber)
>> 
>> However, in the final Info.plist in the app's bundle, this then looks like
>> 
>>   CFBundleVersion
>>   3.1_
>> 
>> Notice the underscore, but the value of CFBuildNumber is gone.
>> "3.1", BTW, is the value I have set under
>> 
>>   Project / Targets / General / Identity / Build
>> 
>> I have tried to change parentheses into curly braces, to no avail.
>> 
>> So, question again: is there a way to use a key/value that was defined 
>> earlier in the plist file
>> to define a value for a later key?
>> I'd like to do that so that the "About" window contains the build number, 
>> too.
>> 
>> 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/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Question about Info.plist's

2020-08-20 Thread Alex Zavatone via Cocoa-dev
I can send anyone who wants it my two projects that increment build numbers if 
you’re interested.

Just let me know.

Alex Zavatone

> On Aug 19, 2020, at 9:45 PM, Michael Hall via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Aug 19, 2020, at 9:04 PM, Michael Hall  wrote:
>> 
>> 
>> I’m not familiar with the Plistbuddy that’s been mentioned. 
> 
> I see that is in fact builtin. Wasn’t aware. Something else I’m curious about 
> is doesn’t this somehow invalidate any application signing that’s been done?
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Invalidating UIImageView's image cache

2020-09-22 Thread Alex Zavatone via Cocoa-dev
It’s probably getting the same image from within the bundle based on the path.  

> On Sep 22, 2020, at 8:12 PM, Eric Lee via Cocoa-dev 
>  wrote:
> 
> Ah maybe it is the use of `imageNamed:`.  I believe that caches the image 
> data in a system cache.  Have you tried `imageWithContentsOfFile:`?
> 
> https://developer.apple.com/documentation/uikit/uiimage/1624123-imagewithcontentsoffile
> 
>> On Sep 22, 2020, at 16:56, Carl Hoefs  wrote:
>> 
>> 
>>> On Sep 22, 2020, at 1:46 PM, Eric Lee via Cocoa-dev 
>>>  wrote:
>>> 
 I don't have a good answer, but I think this may be more that UIImage 
 caches the images, not UIImageView. Maybe you can find something in 
 UIImage's docs/headers?
>>> 
>>> I think you may be on to something.  This WWDC 
>>>  session covers 
>>> optimizing UIImage performance and has some info on what UIImage caches.
>>> 
>>> How are you creating the UIImage?  Are you retaining the UIImage anywhere 
>>> outside of the UIImageView? 
>> 
>> 
>> The path of UIImage creation is as follows:
>> 
>> - For each manually-initiated processing pass of the app, a standard set of 
>> 12 JPG files is written to the sandbox using the OpenCV::imwrite() function, 
>> which creates a JPG from data values. The files have fixed filenames.
>> 
>> - When all 12 JPG files for a pass are written, I then use the following 
>> code snippet to create the UIImages and display them on the main UIImageView:
>> 
>>   NSMutableArray *uiImagesArray = [NSMutableArray new];
>>   for (NSString *file in [[NSFileManager defaultManager] 
>> contentsOfDirectoryAtPath:self.sandboxPath error:NULL]) {
>>   if ([file.pathExtension isEqualToString:@"jpg"]) {
>>   UIImage *tempImage = [UIImage imageNamed:jpgFilename];
>>   if (tempImage) [uiImagesArray addObject:tempImage];
>>   }
>>   }
>>   UIImage *allAGFAImages = [UIImage animatedImageWithImages:uiImagesArray 
>> duration:20.0];
>>   self.imageView.image = allAGFAImages;
>> 
>> - When a new pass of the app is run, the sandbox contents are deleted (see 
>> below), the uiImagesArray variable is set to nil, and the new JPG files are 
>> written, using the same filenames as before. Note that I do not set each 
>> UIImage in the array explicitly to nil.
>> 
>>   [[NSFileManager defaultManager] removeItemAtURL:[NSURL 
>> fileURLWithPath:[self.sandboxPath stringByAppendingPathComponent:file]] 
>> error:&error];
>> 
>> - If I add a uniquing string to the filenames for each pass, the problem 
>> does not present itself. Otherwise the original (old) cached image contents 
>> are displayed until the app is restarted.
>> 
>> - I don't retain the UIImages anywhere other than adding them to the array 
>> in the code snippet above.
>> 
>> -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/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: Rotating NSTextField 90 degrees

2020-09-24 Thread Alex Zavatone via Cocoa-dev
Check out 

frameRotation or 

myView.wantsLayer = YES;
myView.layer.transform = CATransform3DMakeRotation(angle, 
0, 0, 1);

There is this too.

https://developer.apple.com/documentation/appkit/nsview/1483444-rotate 


https://developer.apple.com/documentation/appkit/nsview/1483444-rotatebyangle?language=objc


> On Sep 24, 2020, at 11:09 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> In my MacOS app I need to display some vertical text (normal text rotated 90 
> degrees counterclockwise).
> 
> I don't see anything in NSTextField or Xcode IB that allows a change of 
> orientation. Could NSAttributedString be used to do this, or is there some 
> CoreGraphics way?
> 
> -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/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: Rotating NSTextField 90 degrees

2020-09-24 Thread Alex Zavatone via Cocoa-dev
http://digerati-illuminatus.blogspot.com/2009/09/how-do-you-rotate-nsbutton-nstextfield.html



> On Sep 24, 2020, at 11:09 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> In my MacOS app I need to display some vertical text (normal text rotated 90 
> degrees counterclockwise).
> 
> I don't see anything in NSTextField or Xcode IB that allows a change of 
> orientation. Could NSAttributedString be used to do this, or is there some 
> CoreGraphics way?
> 
> -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/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: Throttling drawing to vertical refresh

2020-10-18 Thread Alex Zavatone via Cocoa-dev
It shouldn’t be too hard to roll your own simply based on milliseconds of a 
timer.

Even a simple 

if (myMilliseconds > nextUpdateTime) {
[updateObject doThatUpdate];
nextUpdateTime = myMilliseconds + msThrottle;
}

lets you get a basic throttle.

Cheers, 
Alex Zavatone

> On Oct 15, 2020, at 2:13 PM, Andreas Falkenhahn via Cocoa-dev 
>  wrote:
> 
> I'm drawing inside an NSView by simply setting its layer's contents to a 
> CGImage which is updated for every frame, e.g. something like this:
> 
>   dp = CGDataProviderCreateWithData(NULL, frameBuf, frameBufSize, NULL);
>   im = CGImageCreate(frameWidth, frameHeight, 8, 32, frameStride, 
> theColorSpace, (CGBitmapInfo) kCGImageAlphaNoneSkipFirst, dp, NULL, FALSE, 
> kCGRenderingIntentDefault);
> 
>   view.layer.contents = (id) im;
>   CGImageRelease(im);
>   CGDataProviderRelease(dp);
> 
> This works fine except that there is no throttle so this will draw as fast as 
> the CPU allows, which of course is a waste of CPU cycles because the monitor 
> only refreshes a certain amount of times per second.
> 
> So is there a convenient way to throttle drawing to the monitor's refresh 
> rate or does this have to be done the hard way by querying the monitor's 
> refresh rate and then setting up a timer which draws in exactly those refresh 
> intervals or how should this be done?
> 
> Note that I'd like to avoid using OpenGL or Metal or whatever is the standard 
> nowadays but I'm mainly interested in an AppKit solution...
> 
> -- 
> Best regards,
> Andreas Falkenhahn  mailto:andr...@falkenhahn.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Throttling drawing to vertical refresh

2020-10-23 Thread Alex Zavatone via Cocoa-dev
Naaah, it’s not that.  The OSes draw code already handles that at a much lower 
level.  You’re just creating what is a maximum update throttle.  You’re not 
blitting pixels in a video card driver.

You can try my simple approach and just declare the next update time to be the 
current time + 1 second.  It should work without screen flicker at all.

We’re not doing low level code.  As far as i know, the MacOS code has a triple 
buffered system that already handles that.

> On Oct 23, 2020, at 10:51 AM, Andreas Falkenhahn  
> wrote:
> 
> The problem with that approach is that I'd need to find out the monitor's 
> refresh rate in order to calculate "nextUpdateTime" and I'm not sure if I can 
> get this information from all monitors reliably.
> 
> On 19.10.2020 at 00:09 Alex Zavatone wrote:
> 
>> It shouldn’t be too hard to roll your own simply based on milliseconds of a 
>> timer.
> 
>> Even a simple 
> 
> if (myMilliseconds >> nextUpdateTime) {
>>[updateObject doThatUpdate];
>>nextUpdateTime = myMilliseconds + msThrottle;
>> }
> 
>> lets you get a basic throttle.
>> 
>> Cheers, 
>> Alex Zavatone
> 
>>> On Oct 15, 2020, at 2:13 PM, Andreas Falkenhahn via Cocoa-dev 
>>>  wrote:
> 
>>> I'm drawing inside an NSView by simply setting its layer's contents to a 
>>> CGImage which is updated for every frame, e.g. something like this:
> 
>>>  dp = CGDataProviderCreateWithData(NULL, frameBuf, frameBufSize, NULL);
>>>  im = CGImageCreate(frameWidth, frameHeight, 8, 32, frameStride, 
>>> theColorSpace, (CGBitmapInfo) kCGImageAlphaNoneSkipFirst, dp, NULL, FALSE, 
>>> kCGRenderingIntentDefault);
> 
>>>  view.layer.contents = (id) im;
>>>  CGImageRelease(im);
>>>  CGDataProviderRelease(dp);
> 
>>> This works fine except that there is no throttle so this will draw as fast 
>>> as the CPU allows, which of course is a waste of CPU cycles because the 
>>> monitor only refreshes a certain amount of times per second.
> 
>>> So is there a convenient way to throttle drawing to the monitor's refresh 
>>> rate or does this have to be done the hard way by querying the monitor's 
>>> refresh rate and then setting up a timer which draws in exactly those 
>>> refresh intervals or how should this be done?
> 
>>> Note that I'd like to avoid using OpenGL or Metal or whatever is the 
>>> standard nowadays but I'm mainly interested in an AppKit solution...
> 
>>> -- 
>>> Best regards,
>>> Andreas Falkenhahn  mailto:andr...@falkenhahn.com
> 
>>> ___
> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
>>> This email sent to z...@mac.com
> 
> 
> 
> 
> -- 
> Best regards,
> Andreas Falkenhahnmailto:andr...@falkenhahn.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: Throttling drawing to vertical refresh

2020-10-23 Thread Alex Zavatone via Cocoa-dev
Just try the simple code I supplied with a 1, 2, second update time.  If you 
find that it doesn’t work, it’s 5 minutes spent.  If you find that it does, 
just figure out the update time that you want.  1/2 a second?  1/10 of a second?

The other thing you can have is a “hasTheDataChanged” setting and only proceed 
to check on the next update time throttle if the data has changed.
 
It’s akin to a dirty bit on a file.

CoreData does that with a hasUpdated or hasBeenUpdated setting so you don’t 
need to resave data needlessly.



> On Oct 23, 2020, at 10:51 AM, Andreas Falkenhahn  
> wrote:
> 
> The problem with that approach is that I'd need to find out the monitor's 
> refresh rate in order to calculate "nextUpdateTime" and I'm not sure if I can 
> get this information from all monitors reliably.
> 
> On 19.10.2020 at 00:09 Alex Zavatone wrote:
> 
>> It shouldn’t be too hard to roll your own simply based on milliseconds of a 
>> timer.
> 
>> Even a simple 
> 
> if (myMilliseconds >> nextUpdateTime) {
>>[updateObject doThatUpdate];
>>nextUpdateTime = myMilliseconds + msThrottle;
>> }
> 
>> lets you get a basic throttle.
>> 
>> Cheers, 
>> Alex Zavatone
> 
>>> On Oct 15, 2020, at 2:13 PM, Andreas Falkenhahn via Cocoa-dev 
>>>  wrote:
> 
>>> I'm drawing inside an NSView by simply setting its layer's contents to a 
>>> CGImage which is updated for every frame, e.g. something like this:
> 
>>>  dp = CGDataProviderCreateWithData(NULL, frameBuf, frameBufSize, NULL);
>>>  im = CGImageCreate(frameWidth, frameHeight, 8, 32, frameStride, 
>>> theColorSpace, (CGBitmapInfo) kCGImageAlphaNoneSkipFirst, dp, NULL, FALSE, 
>>> kCGRenderingIntentDefault);
> 
>>>  view.layer.contents = (id) im;
>>>  CGImageRelease(im);
>>>  CGDataProviderRelease(dp);
> 
>>> This works fine except that there is no throttle so this will draw as fast 
>>> as the CPU allows, which of course is a waste of CPU cycles because the 
>>> monitor only refreshes a certain amount of times per second.
> 
>>> So is there a convenient way to throttle drawing to the monitor's refresh 
>>> rate or does this have to be done the hard way by querying the monitor's 
>>> refresh rate and then setting up a timer which draws in exactly those 
>>> refresh intervals or how should this be done?
> 
>>> Note that I'd like to avoid using OpenGL or Metal or whatever is the 
>>> standard nowadays but I'm mainly interested in an AppKit solution...
> 
>>> -- 
>>> Best regards,
>>> Andreas Falkenhahn  mailto:andr...@falkenhahn.com
> 
>>> ___
> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
>>> This email sent to z...@mac.com
> 
> 
> 
> 
> -- 
> Best regards,
> Andreas Falkenhahnmailto:andr...@falkenhahn.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 parse a log file

2020-10-26 Thread Alex Zavatone via Cocoa-dev
Starting with Gabriel’s comment.

We can see that at line 2, we have this.
NSCFString characterAtIndex:

And on line 1, we have the thrown exception.

If I’m correct, the assumption here is thatthe operation is trying to get the 
first character of a a string at index 0 and there isn’t any, so the exception 
is thrown.  This indicates a nil string.  Looking at the lines until line 6 
(Gabriel says 7 and he is right, but the line is labeled as 6), the array is 
allocated with an object.  This object is probably nil, which caused the error 
on line 2.

Checks can be written to Gabriel and myself.  Or use PayPal.  : D

I hope this is a correct explanation of how Gabriel got to the answer he 
mentioned.

Alex Zavatone


> On Oct 26, 2020, at 5:01 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> From a user, I received a log file that contains an error (see below)
> and a stack trace of my macOS app.
> 
> Is it possible to determine the exact line in the source code where the error 
> occurred?
> 
> Best regards, Gabriel
> 
> 
> Encl:
> excerpt from log.
> "ArtSaverApp"  is my macOS app.
> 
> 
> 2020-10-23 10:47:30.410560-0400 0x2318dError   0x0  
> 6750   0ArtSaverApp: (AppKit) [com.apple.AppKit:General] *** 
> -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object 
> from objects[0]
> 2020-10-23 10:47:30.433412-0400 0x2318dError   0x0  
> 6750   0ArtSaverApp: (AppKit) [com.apple.AppKit:General] (
>   0   CoreFoundation  0x7fff2d796b57 
> __exceptionPreprocess + 250
>   1   libobjc.A.dylib 0x7fff664475bf 
> objc_exception_throw + 48
>   2   CoreFoundation  0x7fff2d84559e 
> -[__NSCFString characterAtIndex:].cold.1 + 0
>   3   CoreFoundation  0x7fff2d8438c4 
> -[__NSPlaceholderArray initWithCapacity:].cold.1 + 0
>   4   CoreFoundation  0x7fff2d69a8ae 
> -[__NSPlaceholderArray initWithObjects:count:] + 154
>   5   CoreFoundation  0x7fff2d6fff7e 
> __createArray + 47
>   6   CoreFoundation  0x7fff2d6fff41 +[NSArray 
> arrayWithObject:] + 25
>   7   ArtSaverApp 0x000109f12466 ArtSaverApp 
> + 46182
>   8   ArtSaverApp 0x000109f1598d ArtSaverApp 
> + 59789
>   9   AppKit  0x7fff2abcd7a7 
> -[NSApplication(NSResponder) sendAction:to:from:] + 299
>   10  AppKit  0x7fff2abcd642 -[NSControl 
> sendAction:to:] + 86
>   11  AppKit  0x7fff2abcd574 __26-[NSCell 
> _sendActionFrom:]_block_invoke + 136
>   12  AppKit  0x7fff2abcd476 -[NSCell 
> _sendActionFrom:] + 171
>   13  AppKit  0x7fff2abcd3bd 
> -[NSButtonCell _sendActionFrom:] + 96
>   14  AppKit  0x7fff2abc969b 
> NSControlTrackMouse + 1745
>   15  AppKit  0x7fff2abc8fa2 -[NSCell 
> trackMouse:inRect:ofView:untilMouseUp:] + 130
>   16  AppKit  0x7fff2abc8e61 
> -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 691
>   17  AppKit  0x7fff2abc81dd -[NSControl 
> mouseDown:] + 748
>   18  AppKit  0x7fff2abc65f0 
> -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4914
>   19  AppKit  0x7fff2ab30e21 
> -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2612
>   20  AppKit  0x7fff2ab301c9 
> -[NSWindow(NSEventRouting) sendEvent:] + 349
>   21  AppKit  0x7fff2ab2e554 
> -[NSApplication(NSEvent) sendEvent:] + 352
>   22  AppKit  0x7fff2a97b5bf 
> -[NSApplication run] + 707
>   23  AppKit  0x7fff2a94d396 
> NSApplicationMain + 777
>   24  libdyld.dylib   0x7fff675efcc9 start + 1
> )
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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 arc

Re: How to parse a log file

2020-10-26 Thread Alex Zavatone via Cocoa-dev
As a note to Jens’s tip, it’s important to keep the .dSWM files for your 
releases so that you can symbolicate your crash logs.  Crashlytics does this 
for you, but the debug symbols are stripped from released builds to try and 
prevent people from reverse engineering your code and to make the executable 
smaller.

If you have access to the build Mac that the execurable was made on, you should 
be able to check in the Organizer window and look for Download Debug Symbols.

And Google for xcode symbolicate binary.

https://developer.apple.com/documentation/xcode/diagnosing_issues_using_crash_reports_and_device_logs/adding_identifiable_symbol_names_to_a_crash_report?language=objc

Alex Zavatone


> On Oct 26, 2020, at 5:19 PM, Jens Alfke via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Oct 26, 2020, at 3:01 PM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> Is it possible to determine the exact line in the source code where the 
>> error occurred?
> 
> The "+ " thing in each stack line is the byte offset from the start of 
> the function, in the machine code. Not super useful by itself … 
> 
> If the symbol is simply "MyAppName + " with no function/method, then no 
> symbols for your code were available at the time of the crash. That means 
> they weren't embedded in the code, and no dSYM file was found.
> 
> Or, if the offset is unrealistically large (like hundreds of KB), then the 
> function/method name is bogus and is simply the nearest named symbol that the 
> stack-dump code could find.
> 
> I believe it's possible to use the .dSYM file that was produced with the 
> release build of _that exact version_ of your app, to convert those offsets 
> into line numbers — there's a tool called "symbolicate" or something like 
> that. I have never done this myself so I don't know the details.
> 
> —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/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: How to parse a log file

2020-10-26 Thread Alex Zavatone via Cocoa-dev
If you upload your build (iOS) to the iTunes connect, I do believe that the 
dSym goes up as well.

Look at the build script for Crashlytics.  It makes sure to upload your dSyms 
and does the symbolicating for iOS apps.

The process already exists with these and other crash tracking tools.

It’s pretty established already.

It’s not impossible to do.

> On Oct 27, 2020, at 12:54 AM, Rob Petrovec via Cocoa-dev 
>  wrote:
> 
> 
> 
>> On Oct 26, 2020, at 10:00 PM, Steven Mills via Cocoa-dev 
>>  wrote:
>> 
>> 
>>> On Oct 26, 2020, at 17:49:59, James Walker via Cocoa-dev 
>>>  wrote:
>>> 
>>> I don't see any "Download Debug Symbols" in the Organizer.  I don't think 
>>> it exists for macOS apps.
>>> 
>>> However, one can right-click on an archive and select "Show In Finder", 
>>> then once in Finder right-click again and Show Package Contents, and drill 
>>> down to find dSyms.  (Usually just one, but if your app builds with a 
>>> private framework, there could be more.)
>> 
>> Yes, Apple needs to remember when writing docs that not all apps are for 
>> mobile! I have to refer to that doc every time I get a user crashlog, once 
>> or twice a year, and it always take the same amount of time to figure out 
>> what they're talking about. I really hope they make this a more automatic 
>> feature in Xcode: Open the project, open a crashlog, choose a menu item to 
>> symbolicate, and let Xcode do the confusing part about loading the dsym from 
>> the archives.
>   While I agree this would be a good thing to have, I don’t see how Xcode 
> could find the dSYM to use given that they are typically ephemeral.  The dSYM 
> is tied to the build.  So if you build your project twice you will have two 
> different dSYMs. Only the dSYM for the build that generated the crash log 
> file will be able to symbolicate it.  So, if you want to symbolicate your 
> crash logs you need to save your dSYM files & resulting app bundle somewhere 
> for each build of your app you publish.  Then you can use them to symbolicate 
> user logs.
>   What Xcode could do, however, is (given a path to a directory 
> containing all the dSYMs for your published builds) parse the log to figure 
> out which dSYM/app bundle pair in the directory to use (probably based on 
> build info and/or version) and symbolicate.  You would also need to take the 
> additional step of properly updating these values in your project for each 
> published build.
> 
>   Either way, that sounds like a reasonable request to make. You should 
> write up a bug report and send it to Apple.
> 
> —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/petrock%40mac.com
>> 
>> This email sent to petr...@mac.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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: Scaling a UIImage

2020-11-02 Thread Alex Zavatone via Cocoa-dev
I’lll dig up a utility class that I made for UIImage that has this as well as 
others.

Cheers.

> On Nov 2, 2020, at 4:59 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> How can I correctly scale a UIImage from 3264x2448 down to 640x480 pixels?
> 
> 
> I have an iOS app that interacts with a macOS server process. The iOS app 
> takes a 3264x2448 camera image, scales it to 640x480 pixels, and makes a JPEG 
> representation of it to send to the server:
> 
>  NSData *dataObj = UIImageJPEGRepresentation(origImage,0.5);
> 
> The server reads the bytes, and creates an NSImage:
> 
>  NSImage *theImage = [[NSImage alloc] initWithData:imageData];
>  NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] 
> initWithData:[theImage TIFFRepresentation]];
> 
> But at this point, imageRep.pixelsWide=1280 and imageRep.pixelsHigh=960!
> 
> If I write theImage to disk and look at it with Preview, it displays onscreen 
> as 640x480 but Preview's Inspector Tool shows it to be 1280x960.
> 
> On the iOS app side, here's the UIImage category method I'm using to scale 
> the image:
> 
> + (UIImage *)imageWithImage:(UIImage *)image 
>   scaledToSize:(CGSize)newSize 
> {
>UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
>[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
>UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
>UIGraphicsEndImageContext();
>return newImage;
> }
> 
> Any suggestions?
> -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/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: Scaling a UIImage

2020-11-04 Thread Alex Zavatone via Cocoa-dev
Sorry for the delay.  I hope these do what you need.
Of course you’ll need to add checks to make sure that you’re not dividing by 
zero or nil.



// Alex Zavatone 4/2/16.
+ (UIImage *)imageWithImage:(UIImage *)image scaledToHeight:(CGFloat)newHeight 
{
CGFloat ratio = newHeight / image.size.height;
CGFloat newWidth = image.size.width * ratio;

CGSize newSize = CGSizeMake(newWidth, newHeight);
//UIGraphicsBeginImageContext(newSize);
// In next line, pass 0.0 to use the current device's pixel scaling factor 
(and thus account for Retina resolution).
// Pass 1.0 to force exact pixel size.
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newWidth, newHeight)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}


+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize 
{
//UIGraphicsBeginImageContext(newSize);
// In next line, pass 0.0 to use the current device's pixel scaling factor 
(and thus account for Retina resolution).
// Pass 1.0 to force exact pixel size.
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}

+ (UIImage *)imageWithImage:(UIImage *)image 
scaledToPercentage:(CGFloat)newScale 
{
CGSize newSize = CGSizeMake(image.size.width * newScale, image.size.width * 
newScale);
UIImage *newImage = [self imageWithImage:image scaledToSize:newSize];

return newImage;
}


Cheers,
Alex Zavatone


> On Nov 3, 2020, at 10:34 AM, James Crate via Cocoa-dev 
>  wrote:
> 
> On Nov 2, 2020, at 5:59 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
>> I have an iOS app that interacts with a macOS server process. The iOS app 
>> takes a 3264x2448 camera image, scales it to 640x480 pixels, and makes a 
>> JPEG representation of it to send to the server:
> 
> I have code that does pretty much the same thing, in Swift though so you’ll 
> need to convert the API calls to ObjC. Since you’re taking a picture, you 
> could use the AVCapturePhoto directly. 
> 
> 
>let capture : AVCapturePhoto
>private lazy var context = CIContext()
> 
>lazy var remotePreviewImage: Data? = {
>guard let cgImage = 
> self.capture.cgImageRepresentation()?.takeRetainedValue() else { return nil }
> 
>var baseImg = CIImage(cgImage: cgImage)
> 
>if let orientation = self.capture.metadata[ 
> String(kCGImagePropertyOrientation) ] as? Int32 {
>baseImg = baseImg.oriented(forExifOrientation: orientation)
>}
> 
>let scalePct = [800.0 / baseImg.extent.size.width, 800.0 / 
> baseImg.extent.size.height].max() ?? 0.3
>let transformedImg = baseImg.transformed(by: CGAffineTransform(scaleX: 
> scalePct, y: scalePct))
>print("generated remote preview image \(transformedImg.extent.size)")
> 
>let colorspace : CGColorSpace = baseImg.colorSpace ?? 
> CGColorSpace(name: CGColorSpace.sRGB)!
>let compressionKey = CIImageRepresentationOption(rawValue: 
> kCGImageDestinationLossyCompressionQuality as String)
>let data = self.context.jpegRepresentation(of: transformedImg, 
> colorSpace: colorspace,
>   options: [compressionKey : 
> 0.6])
>print("photo generated preview \(data?.count ?? 0) bytes")
>return data
>}()
> 
> 
> I had a previous version that used ImageIO. I don’t remember why I switched 
> but I still had the commented code hanging around.  
> 
> //lazy var remotePreviewImage: Data? = {
> //guard let data = self.capture.fileDataRepresentation() else { 
> return nil }
> //guard let src = CGImageSourceCreateWithData(data as NSData, nil) 
> else { return nil }
> //let thumbOpts = [
> //kCGImageSourceCreateThumbnailFromImageAlways: true,
> //kCGImageSourceCreateThumbnailWithTransform: true,
> //kCGImageSourceThumbnailMaxPixelSize: 800,
> //] as [CFString : Any]
> //
> //if let cgImage = CGImageSourceCreateThumbnailAtIndex(src, 0, 
> thumbOpts as CFDictionary) {
> //// create jpg data
> //let data = NSMutableData()
> //
> //if let dest = CGImageDestinationCreateWithData(data, 
> kUTTypeJPEG, 1, nil) {
> //CGImageDestinationAddImage(dest, cgImage, 
> [kCGImageDestinationLossyCompressionQuality: 0.6] as CFDictionary)
> //CGImageDestinationFinalize(dest)
> //}
> //print("getPhoto generated preview \(data.count) bytes for 
> RemoteCapture")
> //return data as Data
> //}
> //return nil
> //}()
> 
> 
> Jim Crate
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-de

Re: Scaling a UIImage

2020-11-04 Thread Alex Zavatone via Cocoa-dev
I’ve got more if you need to desaturate an image, remove all color, tint a 
bitmap, as opposed to using tint, this actually makes a new tinted bitmap, find 
imageInbundle, create enabled and disabled images from source images and so on.

Sometimes we want to use the actual tint, and other times, if we desaturate an 
image and then apply a tint when creating a new image, then we have a new image 
that is always that way.  

This is iOS specific, and you can save them as you want, but I’ve also got a 
save in documents folder as a data, not as image and a load image from docs.

Let me know which ones you might want and I can send them to you offlist.

Cheers,
Alex Zavatone



> On Nov 4, 2020, at 5:10 PM, Carl Hoefs  wrote:
> 
> Thanks for the UIImage category resizing methods! They are quite useful.
> 
> -Carl
> 
>> On Nov 4, 2020, at 2:17 PM, Alex Zavatone > > wrote:
>> 
>> Sorry for the delay.  I hope these do what you need.
>> Of course you’ll need to add checks to make sure that you’re not dividing by 
>> zero or nil.
>> 
>> 
>> 
>> // Alex Zavatone 4/2/16.
>> + (UIImage *)imageWithImage:(UIImage *)image 
>> scaledToHeight:(CGFloat)newHeight 
>> {
>> CGFloat ratio = newHeight / image.size.height;
>> CGFloat newWidth = image.size.width * ratio;
>> 
>> CGSize newSize = CGSizeMake(newWidth, newHeight);
>> //UIGraphicsBeginImageContext(newSize);
>> // In next line, pass 0.0 to use the current device's pixel scaling 
>> factor (and thus account for Retina resolution).
>> // Pass 1.0 to force exact pixel size.
>> UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
>> [image drawInRect:CGRectMake(0, 0, newWidth, newHeight)];
>> UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
>> UIGraphicsEndImageContext();
>> return newImage;
>> }
>> 
>> 
>> + (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize 
>> {
>> //UIGraphicsBeginImageContext(newSize);
>> // In next line, pass 0.0 to use the current device's pixel scaling 
>> factor (and thus account for Retina resolution).
>> // Pass 1.0 to force exact pixel size.
>> UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
>> [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
>> UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
>> UIGraphicsEndImageContext();
>> return newImage;
>> }
>> 
>> + (UIImage *)imageWithImage:(UIImage *)image 
>> scaledToPercentage:(CGFloat)newScale 
>> {
>> CGSize newSize = CGSizeMake(image.size.width * newScale, 
>> image.size.width * newScale);
>> UIImage *newImage = [self imageWithImage:image scaledToSize:newSize];
>> 
>> return newImage;
>> }
>> 
>> 
>> Cheers,
>> Alex Zavatone
>> 
>> 
>>> On Nov 3, 2020, at 10:34 AM, James Crate via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Nov 2, 2020, at 5:59 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
 I have an iOS app that interacts with a macOS server process. The iOS app 
 takes a 3264x2448 camera image, scales it to 640x480 pixels, and makes a 
 JPEG representation of it to send to the server:
>>> 
>>> I have code that does pretty much the same thing, in Swift though so you’ll 
>>> need to convert the API calls to ObjC. Since you’re taking a picture, you 
>>> could use the AVCapturePhoto directly. 
>>> 
>>> 
>>>let capture : AVCapturePhoto
>>>private lazy var context = CIContext()
>>> 
>>>lazy var remotePreviewImage: Data? = {
>>>guard let cgImage = 
>>> self.capture.cgImageRepresentation()?.takeRetainedValue() else { return nil 
>>> }
>>> 
>>>var baseImg = CIImage(cgImage: cgImage)
>>> 
>>>if let orientation = self.capture.metadata[ 
>>> String(kCGImagePropertyOrientation) ] as? Int32 {
>>>baseImg = baseImg.oriented(forExifOrientation: orientation)
>>>}
>>> 
>>>let scalePct = [800.0 / baseImg.extent.size.width, 800.0 / 
>>> baseImg.extent.size.height].max() ?? 0.3
>>>let transformedImg = baseImg.transformed(by: 
>>> CGAffineTransform(scaleX: scalePct, y: scalePct))
>>>print("generated remote preview image \(transformedImg.extent.size)")
>>> 
>>>let colorspace : CGColorSpace = baseImg.colorSpace ?? 
>>> CGColorSpace(name: CGColorSpace.sRGB)!
>>>let compressionKey = CIImageRepresentationOption(rawValue: 
>>> kCGImageDestinationLossyCompressionQuality as String)
>>>let data = self.context.jpegRepresentation(of: transformedImg, 
>>> colorSpace: colorspace,
>>>   options: [compressionKey 
>>> : 0.6])
>>>print("photo generated preview \(data?.count ?? 0) bytes")
>>>return data
>>>}()
>>> 
>>> 
>>> I had a previous version that used ImageIO. I don’t remember why I switched 
>>> but I still had the commented code hanging around.  
>>> 
>>> //lazy var remotePr

Re: NSScrollView's custom content inset

2020-11-05 Thread Alex Zavatone via Cocoa-dev
Care to post a screenshot of what you expect and what’s happening?

Cheers.
Alex Zavatone

> On Nov 5, 2020, at 1:28 PM, Dragan Milić via Cocoa-dev 
>  wrote:
> 
> Hi all,
> 
> What would be the best approach to set custom insets of the contentView 
> (NSClipView) of a NSScrollView? I’ll try to describe the problem in more 
> details…
> 
> I’m trying to make and application look nice on upcoming Big Sur. The fact 
> that Apple has made it so hard for an application (with reasonably 
> complicated UI) to look good on both Bit Sur and older OS version is a topic 
> for some other rant thread… Anyway, I’m trying to get rid of some unwanted 
> NSTableView properties, introduced in Bit Sur.
> 
> I’ve got a NSTableView with a single column. Cells (NSView based) in that 
> single column show some custom content, mostly custom view full of custom 
> Core Text drawing and colouring. It’s very important (visually appealing) if 
> that custom content is stretched through the whole width of the table
> 
> -- 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/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: Missing log output

2020-11-09 Thread Alex Zavatone via Cocoa-dev
I did something super simple in iOS a few years ago.

It simply logged to a file in the Documents directory and if there were more 
than n lines, it would trim the log.  

Then emailing the log was as simple as issuing a mailto: which opened the log 
up in the user’s emailer with a title.

This also allowed me to build a QA screen where I could enable tests and look 
at states of important objects in the running app.

I can send you the code if you want once I find it.

Let me know.
Alex Zavatone



> On Nov 9, 2020, at 3:23 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> At any rate, it's good to plan ahead and use a different logging mechanism, 
>> one without all the complications and unknowns of the system log.
> 
> Yes, I agree.
> 
> I was thinking of implementing a way such that users can just click on kind 
> of a "Send Log" button, and my app would filter out all the log info from, 
> err ..., the system log
> and send it as an attachment with an email to me.
> 
> Would there be an easy / fail-safe way to filter out all the lines in the 
> system log that pertain to my app?
> 
> 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/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: Missing log output

2020-11-09 Thread Alex Zavatone via Cocoa-dev
For logging, my old logging code was replaced by CocoaLumberjack which has a 
max file size and then we would email the log by using 
MFMailComposeViewController and MFMailComposeViewControllerDelegate.

If you wanted to filter out all of the lines you wanted, from the system log, 
you could set up a predicate on the name of your app and return the text that 
is a log message from your app.  If you want, you can also filter on a 
timestamp within now to n weeks or months back.

Cheers.





> On Nov 9, 2020, at 5:09 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> I did something super simple in iOS a few years ago.
> 
> It simply logged to a file in the Documents directory and if there were more 
> than n lines, it would trim the log.  
> 
> Then emailing the log was as simple as issuing a mailto: which opened the log 
> up in the user’s emailer with a title.
> 
> This also allowed me to build a QA screen where I could enable tests and look 
> at states of important objects in the running app.
> 
> I can send you the code if you want once I find it.
> 
> Let me know.
> Alex Zavatone
> 
> 
> 
>> On Nov 9, 2020, at 3:23 PM, Gabriel Zachmann via Cocoa-dev 
>>  wrote:
>> 
>> 
>>> At any rate, it's good to plan ahead and use a different logging mechanism, 
>>> one without all the complications and unknowns of the system log.
>> 
>> Yes, I agree.
>> 
>> I was thinking of implementing a way such that users can just click on kind 
>> of a "Send Log" button, and my app would filter out all the log info from, 
>> err ..., the system log
>> and send it as an attachment with an email to me.
>> 
>> Would there be an easy / fail-safe way to filter out all the lines in the 
>> system log that pertain to my app?
>> 
>> 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/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Missing log output

2020-11-10 Thread Alex Zavatone via Cocoa-dev
In the approaches that I used, I logged to a specific file so that I can simply 
get that file and send that one.   On iOS, it was simply getting the file from 
the docs folder and either using a mailto: URL or using the 
MFMailComposeViewController.

I don’t know if you’re on iOS or MacOS.  

The other nice thing that you can do is is if you are building in non release 
mode, make sure to redirect the output file to 
/users/Shared/myAwesomeLogfile.txt and make sure to add a datestamp to the file 
name every time you start your app so that you have a log for each app session. 
 



> On Nov 10, 2020, at 4:14 AM, Gabriel Zachmann  wrote:
> 
>> 
>> For logging, my old logging code was replaced by CocoaLumberjack
> 
> A quick glance it it looks interesting.
> Do you know (off the top of your head) whether it puts log message into the 
> general syslog?
> That would be nice because it would make it easy to look at the log message 
> on my side using the regular console 'show' command.
> 
>> which has a max file size and then we would email the log by using 
>> MFMailComposeViewController and MFMailComposeViewControllerDelegate.
> 
> Would you mind sharing a bit of code?
> 

Sure.  I’ll look up the old code for you.

>> 
>> If you wanted to filter out all of the lines you wanted, from the system 
>> log, you could set up a predicate on the name of your app and return the 
>> text that is a log message from your app.  If you want, you can also filter 
>> on a timestamp within now to n weeks or months back.
> 
> Do you have code for that approach, too?
> (I am mostly working with Objective-C)

Yeah, I’ll look around.  
___

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

Please do not post admin requests or moderator comments to the list.
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: Missing log output

2020-11-12 Thread Alex Zavatone via Cocoa-dev
Gabe, let me share the decisions and solutions I went over in my attempting to 
solve this on iOS.

In my first logging, all that I wanted was to be able to get the NSLogs out of 
a file that ONLY had the logs from my app.  I sent you the code for that.

In another app, there were 3 sets of transactions that I cared about.  To keep 
the issues relevent, I logged to 3 separate files and then could transfer each 
as needed.  

Some people hate this.  For me, I put a timestamp on each log event and it 
helped me because I could instantly pay attention to ONLY the info that I 
wanted to pay attention to by opening the file for the issues I cared about.

A concern was that “the file could get too big.”  So, I arbitrarily limited 
each file to 10,000 lines of text when writing to them, trimming the oldest 
line if the file length was > 10,000 lines.  

Securlty.  Would the files need to be encrypted?  To get around this, I just 
made sure not to log any PII and used a lookup to get any special info.

Just some background info on the thought process that was behind several of the 
logging that I put in place over the years.

Cheers.
Alex Zavatone

> On Nov 9, 2020, at 3:23 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> At any rate, it's good to plan ahead and use a different logging mechanism, 
>> one without all the complications and unknowns of the system log.
> 
> Yes, I agree.
> 
> I was thinking of implementing a way such that users can just click on kind 
> of a "Send Log" button, and my app would filter out all the log info from, 
> err ..., the system log
> and send it as an attachment with an email to me.
> 
> Would there be an easy / fail-safe way to filter out all the lines in the 
> system log that pertain to my app?
> 
> 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/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: Missing log output

2020-11-12 Thread Alex Zavatone via Cocoa-dev


> On Nov 12, 2020, at 12:50 PM, Gabriel Zachmann  wrote:
> 
>> 
>> Gabe, let me share the decisions and solutions I went over in my attempting 
>> to solve this on iOS.
> 
> Thanks a lot!
> 
> (BTW: I am working on macOS.)
> 
>> 
>> In my first logging, all that I wanted was to be able to get the NSLogs out 
>> of a file that ONLY had the logs from my app.  I sent you the code for that.
> 
> Thanks , that is pretty much what I would like to get, too.
> 
>> 
>> A concern was that “the file could get too big.”  So, I arbitrarily limited 
>> each file to 10,000 lines of text when writing to them, trimming the oldest 
>> line if the file length was > 10,000 lines.  
> 
> Would there be an easy way to do this?

Yeah.  I’ll look up the code now.

Cheers.
Alex Zavatone
___

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

Please do not post admin requests or moderator comments to the list.
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: Keyboard woes

2020-11-17 Thread Alex Zavatone via Cocoa-dev
Which version of Xcode and iOS?  Is it in a Simulator, on the device or both?

> On Nov 17, 2020, at 6:12 PM, Laurent Daudelin via Cocoa-dev 
>  wrote:
> 
> Anybody knows why, all of a sudden, when the keyboard will appear when 
> editing a UITextField or a UITextView, the entire screen seems to freeze? The 
> app in the debugger still to be still running but the interface seems frozen. 
> Trying to rotate doesn’t do anything. There are no errors displayed in the 
> console. I had text fields and text views that were working as usual, I made 
> some changes here and there and now, I can’t remember what I could have done 
> that is causing this problem. It looks like the runloop is not working. I 
> have one case of textfield in a tableview controller that is presented 
> modally like this:
> 
>self.loginController = [APP_DELEGATE.currentStoryboard 
> instantiateViewControllerWithIdentifier:@"LoginTableViewController"];
>self.loginController.nameTextField.text = lastAccountUsed;
>self.loginController.modalPresentationStyle = 
> UIModalPresentationFormSheet;
>[self presentViewController:self.loginController animated:YES 
> completion:nil];
> 
> From the login view controller:
> 
> 
> - (void)viewWillAppear:(BOOL)animated
> {
>   [super viewWillAppear:animated];
>self.nameTextField.enabled = YES;
>   self.nameTextField.text = @"";
>self.passwordTextField.enabled = YES;
>   self.passwordTextField.text = @"";
>   self.loginButton.enabled = NO;
> }
> 
> - (void)viewDidAppear:(BOOL)animated
> {
>   [super viewDidAppear:animated];
>   [self.nameTextField becomeFirstResponder];
> }
> 
> This has worked for a long time and now, when the same code is executed, the 
> interface just freezes. I have another case of a view controller that is 
> presented as a popover and contains a UITextView. As soon as my code tries to 
> set the text view as first responder, the keyboard appears, the text 
> insertion point shows but does not blink.
> 
> I really don’t know what I did :/
> 
> Anybody has any idea?
> 
> -Laurent.
> -- 
> Laurent Daudelin  
> laur...@nemesys-soft.com 
> Skype: LaurentDaudelin
> Logiciels Némésys Software
> http://www.nemesys-soft.com/ 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Keyboard woes

2020-11-17 Thread Alex Zavatone via Cocoa-dev
I know it’s a lot to ask, but what happens if you set up a simple case?  Does 
the same thing happen?

I’ve had to do that many times from back in the Macromedia days until now to 
narrow down what’s causing the problem.  When faced with such strangeness as 
this, try to see if you can set up a simple case to reproduce it.  Then compare 
the differences between the two and narrow it down from there.



> On Nov 17, 2020, at 9:05 PM, Laurent Daudelin  
> wrote:
> 
> Xcode release 12.2, both iOS 13 and 14. Both on device and simulator. The 
> work I did on the app was trying to get the split view controller with the 
> new APIs to behave like when used with the old APIs. I finally gave up after 
> trying every possible combination of style and behavior. My app was 
> originally designed 5 years ago. There might still be stuff that is impacting 
> the new APIs, although I did search for all occurrences of the split view 
> controller and isolated the few calls I had with @available to leave the new 
> APIs do their job. But, I don’t see how this is related to all textfields and 
> textviews now being unable to work with the keyboard!
> 
> -Laurent.
> -- 
> Laurent Daudelin  
> laur...@nemesys-soft.com
> Skype: LaurentDaudelin
> Logiciels Némésys Software
> http://www.nemesys-soft.com/
> 
>> On Nov 17, 2020, at 19:51, Alex Zavatone  wrote:
>> 
>> Which version of Xcode and iOS?  Is it in a Simulator, on the device or both?
>> 
>>> On Nov 17, 2020, at 6:12 PM, Laurent Daudelin via Cocoa-dev 
>>>  wrote:
>>> 
>>> Anybody knows why, all of a sudden, when the keyboard will appear when 
>>> editing a UITextField or a UITextView, the entire screen seems to freeze? 
>>> The app in the debugger still to be still running but the interface seems 
>>> frozen. Trying to rotate doesn’t do anything. There are no errors displayed 
>>> in the console. I had text fields and text views that were working as 
>>> usual, I made some changes here and there and now, I can’t remember what I 
>>> could have done that is causing this problem. It looks like the runloop is 
>>> not working. I have one case of textfield in a tableview controller that is 
>>> presented modally like this:
>>> 
>>>  self.loginController = [APP_DELEGATE.currentStoryboard 
>>> instantiateViewControllerWithIdentifier:@"LoginTableViewController"];
>>>  self.loginController.nameTextField.text = lastAccountUsed;
>>>  self.loginController.modalPresentationStyle = 
>>> UIModalPresentationFormSheet;
>>>  [self presentViewController:self.loginController animated:YES 
>>> completion:nil];
>>> 
>>> From the login view controller:
>>> 
>>> 
>>> - (void)viewWillAppear:(BOOL)animated
>>> {
>>> [super viewWillAppear:animated];
>>>  self.nameTextField.enabled = YES;
>>> self.nameTextField.text = @"";
>>>  self.passwordTextField.enabled = YES;
>>> self.passwordTextField.text = @"";
>>> self.loginButton.enabled = NO;
>>> }
>>> 
>>> - (void)viewDidAppear:(BOOL)animated
>>> {
>>> [super viewDidAppear:animated];
>>> [self.nameTextField becomeFirstResponder];
>>> }
>>> 
>>> This has worked for a long time and now, when the same code is executed, 
>>> the interface just freezes. I have another case of a view controller that 
>>> is presented as a popover and contains a UITextView. As soon as my code 
>>> tries to set the text view as first responder, the keyboard appears, the 
>>> text insertion point shows but does not blink.
>>> 
>>> I really don’t know what I did :/
>>> 
>>> Anybody has any idea?
>>> 
>>> -Laurent.
>>> -- 
>>> Laurent Daudelin
>>> laur...@nemesys-soft.com 
>>> Skype: LaurentDaudelin  
>>> Logiciels Némésys Software  
>>> http://www.nemesys-soft.com/ 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>>> 
>>> This email sent to z...@mac.com
> 

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Bug reporting again.

2020-11-22 Thread Alex Zavatone via Cocoa-dev
I’ve found a bug in Swift’s loadView for UIViewController on iOS that I’d like 
to report.  Swift.org tells us to use https://bugreport.apple.com which returns 
 “bugreport.apple.com’s server IP address could not be found.”.

Feedback.apple.com seems not related to bug reporting.  

I’ve created two projects that show expected behaviour for loadView in 
UIViewController, and how in Swift, what is indicated in the header for 
loadView is not followed.

How can I report this to Apple or the Swift team?

Essentially, what this header information is telling us is not followed in 
Swift 5.x, breaking over 13 years of precident.  Swift does not attempt to load 
an XIB that matches the name of the class being instantiated if the view is 
nil, counter to what the header file says it should do.

From  UIViewController.h

/*
  The designated initializer. If you subclass UIViewController, you must 
call the super implementation of this
  method, even if you aren't using a NIB.  (As a convenience, the default 
init method will do this for you,
  and specify nil for both of this methods arguments.) In the specified 
NIB, the File's Owner proxy should
  have its class set to your view controller subclass, with the view outlet 
connected to the main view. If you
  invoke this method with a nil nib name, then this class' -loadView method 
will attempt to load a NIB whose
  name is the same as your view controller's class. If no such NIB in fact 
exists then you must either call
  -setView: before -view is invoked, or override the -loadView method to 
set up your views programatically.
*/



The behaviour below is what is simply not happening.

If you
  invoke this method with a nil nib name, then this class' -loadView method 
will attempt to load a NIB whose
  name is the same as your view controller's class.


The easyiest way to reproduce this is to simply create a ViewController with an 
XIB and make it the initial view controller in a storyboard.  
Add a label to the XIB to make it obvious when or if the XIB loads.  
In the storyboard scene for that viewController, delete the top level view to 
create the nil condition and run the app.

In an Objective-C app on iOS, the expected XIB loads.
In a Swift app on iOS, the view is empty and no XIB loads.

This is validated in the View Debugger.

So, how can I report this?

Thanks in advance.
Alex Zavatone


___

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

Please do not post admin requests or moderator comments to the list.
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: Bug reporting again.

2020-11-22 Thread Alex Zavatone via Cocoa-dev


> On Nov 22, 2020, at 3:08 PM, Ben Kennedy  wrote:
> 
> 
>> On 22 Nov 2020, at 12:45 pm, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> I’ve found a bug in Swift’s loadView for UIViewController on iOS that I’d 
>> like to report.  Swift.org tells us to use https://bugreport.apple.com which 
>> returns  “bugreport.apple.com’s server IP address could not be found.”.
> 
> Apple replaced Bug Reporter with Feedback Assistant months ago: 
> https://developer.apple.com/bug-reporting/
> 
> The web site you're looking for is https://feedbackassistant.apple.com.
> 
> -ben
> 

Yeah, odd.  That’s what I loaded earlier but it didn’t being up any content to 
the right of the issue pane on the left.

Aaaand of course it opens just fine now!  

Rocking, Ben.  Thanks a million +/- inflation.

Happy Sunday.
Alex Zavatone
___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev
Why not use your top level NSUserDefaults  as a dictionary and use each monitor 
name as a key for each object in the dictionary?  Is that too clunky?

https://developer.apple.com/documentation/foundation/nsuserdefaults

A default object must be a property list—that is, an instance of (or for 
collections, a combination of instances of) NSData 
, NSString 
, NSNumber 
, NSDate 
, NSArray 
, or NSDictionary 
.

Am I missing something here?

Alex Zavatone

> On Apr 2, 2021, at 4:05 PM, 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/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: Several different NSUserDefaults in the same app?

2021-04-04 Thread Alex Zavatone via Cocoa-dev
And if you want a nice simple HMAC256 encoding class to make the results 
securer if you want, I’ll happily toss one your way.

> On Apr 4, 2021, at 2:22 PM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> 
>> 
>> It appears you are trying to get NSUserDefaults to do something that Apple 
>> doesn?t want it to do these days. Why not create your own defaults,
>> writing the data to a dictionary that is then written to a file that you 
>> save in the ~/Library/Preferences folder, with a name of your choice?
> 
> I can see that this would work well.
> 
> It didn't seem to me that one solution is superior to another.
> So, I have now implemented one dictionary per display that my app sees,
> and store those dictionaries in the NSUserDefaults, with the display name as 
> the key.
> 
> Thanks a lot for all your help and ideas!
> 
> 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/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: Scroller and not apple's mouse

2021-04-12 Thread Alex Zavatone via Cocoa-dev
What are you trying to do?  Which platform is this for?  Which language are you 
using?

Regards,
Alex Zavatone

> On Apr 12, 2021, at 2:30 AM, IOS NACSPORT via Cocoa-dev 
>  wrote:
> 
> Hi,
> 
> I don't kown is the correct place, In a NSScroller, when I conect the 
> external mouse, not apple's mouse, the scroll change and show always, the 
> problem is that I can't change its background color. How could it? or at 
> least make it clear.
> 
> 
> Regards
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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: Scroller and not apple's mouse

2021-04-13 Thread Alex Zavatone via Cocoa-dev
Please show your code.  Otherwise, we have little to go on.

Sent from my iPhone

> On Apr 13, 2021, at 2:41 AM, Allan Odgaard via Cocoa-dev 
>  wrote:
> 
> Probably two things relevant here.
> 
> One is General in system preferences which look like this:
> 
> ![](cid:2C16BC1B-F302-426F-9F6A-665F55C99045@simplit.com "PastedImage.png")
> 
> A Magic Mouse may count as a “track pad” so if you have this setting to 
> automatic, the scrollers will only be shown when scrolling.
> 
> You can manually override the scroller setting: 
> https://developer.apple.com/documentation/appkit/nsscroller/1523591-scrollerstyle
> 
> The style it sounds like you prefer is NSScrollerStyleOverlay.
> 
> However, I would discourage you from changing this.
> 
> 
>> On 13 Apr 2021, at 9:24, IOS NACSPORT via Cocoa-dev wrote:
>> 
>> Hi,
>> 
>> I connect any non-Apple mouse, turn off the Apple mouse and the scroll 
>> shows, in it I can´t change the background color. I used swift and macOS. 
>> Without another mouse, only magic mouse I can change this color without 
>> problem.
>> 
>> Regards
>> 
>>> El 12/4/21 a las 23:40, Jack Brindle escribió:
>>> What is the mouse, and is there any installed software involved that goes 
>>> with the mouse?
>>> 
>>> Jack
>>> 
>>> 
 On Apr 12, 2021, at 12:30 AM, IOS NACSPORT via Cocoa-dev 
  wrote:
 
 Hi,
 
 I don't kown is the correct place, In a NSScroller, when I conect the 
 external mouse, not apple's mouse, the scroll change and show always, the 
 problem is that I can't change its background color. How could it? or at 
 least make it clear.
 
 
 Regards
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/jackbrindle%40me.com
 
 This email sent to jackbrin...@me.com
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/lists%2Bcocoa-dev%40simplit.com
>> 
>> This email sent to lists+cocoa-...@simplit.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Scroller and not apple's mouse

2021-04-13 Thread Alex Zavatone via Cocoa-dev
And WHICH non-Apple mice are you using?

Sent from my iPhone

> On Apr 13, 2021, at 8:44 AM, Alex Zavatone  wrote:
> 
> Please show your code.  Otherwise, we have little to go on.
> 
> Sent from my iPhone
> 
>> On Apr 13, 2021, at 2:41 AM, Allan Odgaard via Cocoa-dev 
>>  wrote:
>> 
>> Probably two things relevant here.
>> 
>> One is General in system preferences which look like this:
>> 
>> ![](cid:2C16BC1B-F302-426F-9F6A-665F55C99045@simplit.com "PastedImage.png")
>> 
>> A Magic Mouse may count as a “track pad” so if you have this setting to 
>> automatic, the scrollers will only be shown when scrolling.
>> 
>> You can manually override the scroller setting: 
>> https://developer.apple.com/documentation/appkit/nsscroller/1523591-scrollerstyle
>> 
>> The style it sounds like you prefer is NSScrollerStyleOverlay.
>> 
>> However, I would discourage you from changing this.
>> 
>> 
 On 13 Apr 2021, at 9:24, IOS NACSPORT via Cocoa-dev wrote:
>>> 
>>> Hi,
>>> 
>>> I connect any non-Apple mouse, turn off the Apple mouse and the scroll 
>>> shows, in it I can´t change the background color. I used swift and macOS. 
>>> Without another mouse, only magic mouse I can change this color without 
>>> problem.
>>> 
>>> Regards
>>> 
 El 12/4/21 a las 23:40, Jack Brindle escribió:
 What is the mouse, and is there any installed software involved that goes 
 with the mouse?
 
 Jack
 
 
> On Apr 12, 2021, at 12:30 AM, IOS NACSPORT via Cocoa-dev 
>  wrote:
> 
> Hi,
> 
> I don't kown is the correct place, In a NSScroller, when I conect the 
> external mouse, not apple's mouse, the scroll change and show always, the 
> problem is that I can't change its background color. How could it? or at 
> least make it clear.
> 
> 
> Regards
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/jackbrindle%40me.com
> 
> This email sent to jackbrin...@me.com
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/lists%2Bcocoa-dev%40simplit.com
>>> 
>>> This email sent to lists+cocoa-...@simplit.com
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: WKWebView rejecting keyboard input

2021-04-15 Thread Alex Zavatone via Cocoa-dev
Hi Rob. One thing that I learned back in QA is that when we have a working 
sample and one non-working one, duplicate both, point your app to use them, & 
start removing items from the one that doesn’t work until you get back down to 
either it working or end up with identical items in the working sample and it 
still doesn’t work.

Have you tried that yet?

Let us know.
Alex Zavatone

> On Apr 15, 2021, at 9:42 AM, Robert Walsh via Cocoa-dev 
>  wrote:
> 
> I have an Objective-C application that creates a WKWebView to collect form 
> input.  The form has a label, an input (password) field, and two buttons.  
> When the form is shown inside the web view by the application, the user can 
> click the buttons but cannot enter text into the input field.  The system 
> plays a sound to indicate that the key was rejected.  I've tried adding a 
> text area element to the form just to see if the problem is with the input 
> field itself, but the user cannot type in the text area either.  If I take 
> the same HTML/stylesheet content and open it in Safari, the input field 
> accepts keyboard input.
> 
> There is another area of the application that shows a different web page in 
> the same WKWebView component.  That page, too, contains a form with an input 
> field, and the user can type into that one.
> 
> I am using a WKWebView subclass so that I can trap mouse down events, but I 
> do not have any overloads for keyboard event handlers.
> 
> I'm having trouble determining where (e.g., by what component) the keys are 
> being blocked and why they are allowed on one page but not another.
> 
> Thanks!
> Rob Walsh
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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


iOS, handling communicating to a server with a "Not Trusted" SSL cert.

2021-04-17 Thread Alex Zavatone via Cocoa-dev
I just came across this the other day and now need to do something about it.  
Am looking to see if anyone else has had to handle this and profit off of the 
wisdom of those who have suffered through it before.

Currently, I’m planning on testing out an NSAPPTransportSecurity exception in 
the plist on the offending domain.  But I’d also like to see what’s wrong with 
the cert.  

Will check out the recommendations here too.  
https://support.apple.com/en-us/HT210176

And the discussion here.  
https://developer.apple.com/forums/thread/655074?login=true


And the notice here.  https://support.apple.com/en-us/HT211025

TLS server certificates issued on or after September 1, 2020 00:00 
GMT/UTC must not have a validity period greater than 398 days.

Connections to TLS servers violating these new requirements will fail. 


Another question, is there a way to make sure to get these announcements from 
Apple in emails?  Am I the only person who is constantly surprised by these new 
policies?

Thanks in advance.
Alex Zavatone



___

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

Please do not post admin requests or moderator comments to the list.
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: iOS, handling communicating to a server with a "Not Trusted" SSL cert.

2021-04-20 Thread Alex Zavatone via Cocoa-dev
Thanks Matt.  A world of good information in there.  

One thing that’s odd though is that we’re issuing an NSURL loadRequest to a 
WKWebView.  I’d expect that a simple blanket NSAppTransportSecurity allow 
arbitrary loads or an allow arbtrary loads in web content would allow the 
invalud cert to be bypassed, but the error -1202 is still being caught and the 
error of “The  certificate for this server is invalid” still gets caught in a 
navigation error on the web delegate.

Any ideas?

Thanks in advance,
Alex Zavatone 

> On Apr 18, 2021, at 11:54 AM, Matt Eaton  wrote:
> 
>> But I’d also like to see what’s wrong with the cert.  
> 
> If this a certificate that you control then I would recommend trying to take 
> a look at how to fix your certificate rather than adding an ATS exception or 
> overriding trust evaluation on the client side.  This would provide the best 
> long term solution.
> 
> As to how to solve your problem; "Not Trusted," can stem from a variety of 
> issues when a policy is evaluated on the client side.  HT211025 and HT210176 
> provide an excellent outline for why a certificate can end up in this state.  
> A few things to check:
> 
> * Who is the issuer (CA) of the leaf certificate on the server side that is 
> being evaluated? Is it an In-House CA or is it a CA that contains a root in 
> the device's trust store? <https://support.apple.com/en-us/HT212140 
> <https://support.apple.com/en-us/HT212140>>.  The reason why I mention this 
> is because certificates that are issued from a CA that has a root in the 
> trust store generally fulfill the requirements of outlined by HT211025 and 
> HT210176.  If the leaf is issued from an In-House CA then a chain of trust 
> may not be able to be created during trust evaluation, or one of the other 
> requirements may not be getting fulfilled from HT211025 and HT210176 and this 
> could be the breakdown.
> 
> * If the leaf comes from the CA that contains a root in the trust store then 
> check the validity period of the certificate.  This can be done by checking 
> the "Not Valid Before," and "Not Valid After" time stamps on the certificate 
> to see if they fit into the requirements outline by HT211025 and HT210176.
> 
> * Is the certificate being trusted via an external CT (Certificate 
> Transparency) log or an embedded SCT?  This can usually be done with a SCT 
> (Signed Certificate Timestamp) embedded in the certificate and then the 
> certificate can be evaluated via a TLS extension.  Other forms of validation 
> include a client making a OCSP request to check the status of the certificate 
> from a log operator.  These details can be confirmed by looking at a packet 
> trace with the certificate in question.  
> 
> The best way to see what is wrong with the certificate in question is to 
> check the certificate details or take a packet trace and review the 
> information being exchanged in the client hello / server hello during the TLS 
> handshake.  This should give you a baseline for what is happening.
> 
> If you need to setup test cases for these scenarios, try using BadSSL, 
> (<https://badssl.com <https://badssl.com/>>) to test out whether you are 
> correctly handling many of the common failures that you can run into when 
> evaluating trust.
> 
> 
>> On Apr 17, 2021, at 1:32 PM, Alex Zavatone via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> I just came across this the other day and now need to do something about it. 
>>  Am looking to see if anyone else has had to handle this and profit off of 
>> the wisdom of those who have suffered through it before.
>> 
>> Currently, I’m planning on testing out an NSAPPTransportSecurity exception 
>> in the plist on the offending domain.  But I’d also like to see what’s wrong 
>> with the cert.  
>> 
>> Will check out the recommendations here too.  
>> https://support.apple.com/en-us/HT210176
>> 
>> And the discussion here.  
>> https://developer.apple.com/forums/thread/655074?login=true
>> 
>> 
>> And the notice here.  https://support.apple.com/en-us/HT211025
>> 
>>  TLS server certificates issued on or after September 1, 2020 00:00 
>> GMT/UTC must not have a validity period greater than 398 days.
>> 
>>  Connections to TLS servers violating these new requirements will fail. 
>> 
>> 
>> Another question, is there a way to make sure to get these announcements 
>> from Apple in emails?  Am I the only person who is constantly surprised by 
>> these new policies?
>> 
>> Thanks in advance.
>> Alex Zavatone
>> 
>> 
>> 
>> _

Re: iOS, handling communicating to a server with a "Not Trusted" SSL cert.

2021-04-22 Thread Alex Zavatone via Cocoa-dev
FYI, the workaround was the WKWebViewDelegate equivalent of responding to a 
URLConnection challenge/response.

Once that was called, check the securityref and if it’s not nil, set the proper 
trust exceptions.  If it is nil, skip that and pass nil to the callback.

The webView ends up loading the URL if there is a challenge or not.

Matt’s detail about the iOS 14 trusted cert root list piggybacks off of the iOS 
13 changes which limit SSL certs to 1 year.  These details really help narrow 
down the many reasons why the certs are no longer valid.  

Super helpful.  I thank you again.

Hopefully, this will also help out others who will run into this.

Best, and thanks again.

Alex Zavatone

> On Apr 20, 2021, at 3:32 PM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> Thanks Matt.  A world of good information in there.  
> 
> One thing that’s odd though is that we’re issuing an NSURL loadRequest to a 
> WKWebView.  I’d expect that a simple blanket NSAppTransportSecurity allow 
> arbitrary loads or an allow arbtrary loads in web content would allow the 
> invalud cert to be bypassed, but the error -1202 is still being caught and 
> the error of “The  certificate for this server is invalid” still gets caught 
> in a navigation error on the web delegate.
> 
> Any ideas?
> 
> Thanks in advance,
> Alex Zavatone 
> 
>> On Apr 18, 2021, at 11:54 AM, Matt Eaton  wrote:
>> 
>>> But I’d also like to see what’s wrong with the cert.  
>> 
>> If this a certificate that you control then I would recommend trying to take 
>> a look at how to fix your certificate rather than adding an ATS exception or 
>> overriding trust evaluation on the client side.  This would provide the best 
>> long term solution.
>> 
>> As to how to solve your problem; "Not Trusted," can stem from a variety of 
>> issues when a policy is evaluated on the client side.  HT211025 and HT210176 
>> provide an excellent outline for why a certificate can end up in this state. 
>>  A few things to check:
>> 
>> * Who is the issuer (CA) of the leaf certificate on the server side that is 
>> being evaluated? Is it an In-House CA or is it a CA that contains a root in 
>> the device's trust store? <https://support.apple.com/en-us/HT212140 
>> <https://support.apple.com/en-us/HT212140>>.  The reason why I mention this 
>> is because certificates that are issued from a CA that has a root in the 
>> trust store generally fulfill the requirements of outlined by HT211025 and 
>> HT210176.  If the leaf is issued from an In-House CA then a chain of trust 
>> may not be able to be created during trust evaluation, or one of the other 
>> requirements may not be getting fulfilled from HT211025 and HT210176 and 
>> this could be the breakdown.
>> 
>> * If the leaf comes from the CA that contains a root in the trust store then 
>> check the validity period of the certificate.  This can be done by checking 
>> the "Not Valid Before," and "Not Valid After" time stamps on the certificate 
>> to see if they fit into the requirements outline by HT211025 and HT210176.
>> 
>> * Is the certificate being trusted via an external CT (Certificate 
>> Transparency) log or an embedded SCT?  This can usually be done with a SCT 
>> (Signed Certificate Timestamp) embedded in the certificate and then the 
>> certificate can be evaluated via a TLS extension.  Other forms of validation 
>> include a client making a OCSP request to check the status of the 
>> certificate from a log operator.  These details can be confirmed by looking 
>> at a packet trace with the certificate in question.  
>> 
>> The best way to see what is wrong with the certificate in question is to 
>> check the certificate details or take a packet trace and review the 
>> information being exchanged in the client hello / server hello during the 
>> TLS handshake.  This should give you a baseline for what is happening.
>> 
>> If you need to setup test cases for these scenarios, try using BadSSL, 
>> (<https://badssl.com <https://badssl.com/>>) to test out whether you are 
>> correctly handling many of the common failures that you can run into when 
>> evaluating trust.
>> 
>> 
>>> On Apr 17, 2021, at 1:32 PM, Alex Zavatone via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> I just came across this the other day and now need to do something about 
>>> it.  Am looking to see if anyone else has had to handle this and profit off 
>>> of the wisdom of those who have suffered through it before.
>>> 
>>> Currently, I’m planning on 

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

2021-05-08 Thread Alex Zavatone via Cocoa-dev
I’m reading a configuration plist like so.

NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL success = [fileManager fileExistsAtPath:filePath];

if (success) {
  
_configurationDictionary = [[NSMutableDictionary 
alloc]initWithDictionary:[NSDictionary dictionaryWithContentsOfFile:filePath]];




In some cases, I want the plist to be a dictionary.  In others, I want it to be 
an array.

How would anyone recommend to make this a generic method to that could handle 
if the contents of the plist was an array or a dictionary?

Thanks in advance.
Alex Zavatone

___

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

Please do not post admin requests or moderator comments to the list.
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-08 Thread Alex Zavatone via Cocoa-dev
Well, what I’m not sure about are how to store the results internally.  Do I 
declare both an NSArray and an NSDictionary and check to see which one ended up 
getting the proper result?

Is there a class of object that is a collection that is - either an array or 
dictionary? Of course, that’s what a collection is, but I’ve never come across 
needing to structure code to handle ether an array or a dictionary.

In the text of the article, “A property list is itself an array or dictionary 
that contains only NSData 
<https://developer.apple.com/documentation/foundation/nsdata>, NSString 
<https://developer.apple.com/documentation/foundation/nsstring>, NSArray 
<https://developer.apple.com/documentation/foundation/nsarray>, NSDictionary 
<https://developer.apple.com/documentation/foundation/nsdictionary>, NSDate 
<https://developer.apple.com/documentation/foundation/nsdate>, and NSNumber 
<https://developer.apple.com/documentation/foundation/nsnumber> objects.”

It seems like just stalling the inevitable.  

+ (NSData <https://developer.apple.com/documentation/foundation/nsdata> 
*)dataWithPropertyList:(id)plist 
  format:(NSPropertyListFormat 
<https://developer.apple.com/documentation/foundation/nspropertylistformat>)format
 
 options:(NSPropertyListWriteOptions 
<https://developer.apple.com/documentation/foundation/nspropertylistwriteoptions>)opt
 
   error:(out NSError 
<https://developer.apple.com/documentation/foundation/nserror> * _Nullable 
*)error;

OK.  So once I get an NSData object, then I need to decode it and see if it’s 
an array or dictionary, which ends up being the same problem I already have.

So, what would be the next step after that?

Thanks, Ben.

Alex Zavatone


> On May 8, 2021, at 7:25 PM, Ben Kennedy  wrote:
> 
> Sounds like NSPropertyListSerialization is what you’re after.
> 
> https://developer.apple.com/documentation/foundation/nspropertylistserialization
>  
> <https://developer.apple.com/documentation/foundation/nspropertylistserialization>
> 
> b
> 
> Sent from my iPhone
> 
>> On May 8, 2021, at 5:12 PM, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> I’m reading a configuration plist like so.
>> 
>> NSFileManager *fileManager = [NSFileManager defaultManager];
>>BOOL success = [fileManager fileExistsAtPath:filePath];
>> 
>>if (success) {
>> 
>>_configurationDictionary = [[NSMutableDictionary 
>> alloc]initWithDictionary:[NSDictionary 
>> dictionaryWithContentsOfFile:filePath]];
>> 
>> 
>> 
>> 
>> In some cases, I want the plist to be a dictionary.  In others, I want it to 
>> be an array.
>> 
>> How would anyone recommend to make this a generic method to that could 
>> handle if the contents of the plist was an array or a dictionary?
>> 
>> Thanks in advance.
>> Alex Zavatone
> 

___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev


> On May 8, 2021, at 7:42 PM, Ben Kennedy  wrote:
> 
> 
>> On 8 May 2021, at 5:32 pm, Alex Zavatone  wrote:
>> 
>> Well, what I’m not sure about are how to store the results internally.  Do I 
>> declare both an NSArray and an NSDictionary and check to see which one ended 
>> up getting the proper result?
> 
> Call -[propertyListWithData:options:format:error:], and examine what kind of 
> object it returns. Process or store it accordingly.
> 
>> Is there a class of object that is a collection that is - either an array or 
>> dictionary? Of course, that’s what a collection is, but I’ve never come 
>> across needing to structure code to handle ether an array or a dictionary.
> 
> It sounds like you might need to rethink your data model a bit.

That’s what I’m trying to do!  : D

> I mean, you could hold the object in a variable of type `id` or `AnyObject` 
> (ObjC or Swift, accordingly), but that will just create hassles for 
> consumers. What format makes the most sense for the model? Transform the 
> other one into it if needed.

That’s what I was trying to avoid.  I’d simply like to see if there is a better 
way, but it might be OK to bring it in as id, check the class and then save as 
either dictionary or array.  Once it’s read only once it’s in.  

This might be a fun case for a dict or array wrapper class for my dict or array 
plist reader thanks to your tips. 

> 
>> + (NSData *)dataWithPropertyList:(id)plist 
>> 
>> OK.  So once I get an NSData object, then I need to decode it and see if 
>> it’s an array or dictionary, which ends up being the same problem I already 
>> have.
> 
> No, you have it backwards. That method is useful if you want to create a 
> plist file out of an array, dictionary, etc. To do the opposite, use 
> propertyListWithData:….
> 

Huh? + (NSData *)dataWithPropertyList:(id)plist returns an NSData object.  
Isn’t the propertyListWithData the one that creates a property list out of 
NSData?  

Anyway, thanks man!  Good stuff.

Thanks and happy Sunday.  

Alex Zavatone.
___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev


> On May 8, 2021, at 9:55 PM, Gerd Knops  wrote:
> 
> NSPropertyListSerialization returns an id.
> 
> From there you can do
> 
> if([object isKindOfClass:NSArray.class])
> {
>   NSArray *array=object; // Not really needed, but gives hints to the 
> compiler
>   ...
> }
> else if([object isKindOfClass:NSDitctionary.class])
> {
>   ...
> }
> ...
> 

Well, hell!  There we go.  Thanks Gerd!  That’s great!

Best,
Alex Zavatone

> 
> 
>> On May 8, 2021, at 19:32, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> Well, what I’m not sure about are how to store the results internally.  Do I 
>> declare both an NSArray and an NSDictionary and check to see which one ended 
>> up getting the proper result?
>> 
>> Is there a class of object that is a collection that is - either an array or 
>> dictionary? Of course, that’s what a collection is, but I’ve never come 
>> across needing to structure code to handle ether an array or a dictionary.
>> 
>> In the text of the article, “A property list is itself an array or 
>> dictionary that contains only NSData 
>> <https://developer.apple.com/documentation/foundation/nsdata>, NSString 
>> <https://developer.apple.com/documentation/foundation/nsstring>, NSArray 
>> <https://developer.apple.com/documentation/foundation/nsarray>, NSDictionary 
>> <https://developer.apple.com/documentation/foundation/nsdictionary>, NSDate 
>> <https://developer.apple.com/documentation/foundation/nsdate>, and NSNumber 
>> <https://developer.apple.com/documentation/foundation/nsnumber> objects.”
>> 
>> It seems like just stalling the inevitable.  
>> 
>> + (NSData <https://developer.apple.com/documentation/foundation/nsdata> 
>> *)dataWithPropertyList:(id)plist 
>> format:(NSPropertyListFormat 
>> <https://developer.apple.com/documentation/foundation/nspropertylistformat>)format
>>  
>>options:(NSPropertyListWriteOptions 
>> <https://developer.apple.com/documentation/foundation/nspropertylistwriteoptions>)opt
>>  
>>  error:(out NSError 
>> <https://developer.apple.com/documentation/foundation/nserror> * _Nullable 
>> *)error;
>> 
>> OK.  So once I get an NSData object, then I need to decode it and see if 
>> it’s an array or dictionary, which ends up being the same problem I already 
>> have.
>> 
>> So, what would be the next step after that?
>> 
>> Thanks, Ben.
>> 
>> Alex Zavatone
>> 
>> 
>>> On May 8, 2021, at 7:25 PM, Ben Kennedy  wrote:
>>> 
>>> Sounds like NSPropertyListSerialization is what you’re after.
>>> 
>>> https://developer.apple.com/documentation/foundation/nspropertylistserialization
>>>  
>>> <https://developer.apple.com/documentation/foundation/nspropertylistserialization>
>>> 
>>> b
>>> 
>>> Sent from my iPhone
>>> 
>>>> On May 8, 2021, at 5:12 PM, Alex Zavatone via Cocoa-dev 
>>>>  wrote:
>>>> 
>>>> I’m reading a configuration plist like so.
>>>> 
>>>> NSFileManager *fileManager = [NSFileManager defaultManager];
>>>>  BOOL success = [fileManager fileExistsAtPath:filePath];
>>>> 
>>>>  if (success) {
>>>> 
>>>>  _configurationDictionary = [[NSMutableDictionary 
>>>> alloc]initWithDictionary:[NSDictionary 
>>>> dictionaryWithContentsOfFile:filePath]];
>>>> 
>>>> 
>>>> 
>>>> 
>>>> In some cases, I want the plist to be a dictionary.  In others, I want it 
>>>> to be an array.
>>>> 
>>>> How would anyone recommend to make this a generic method to that could 
>>>> handle if the contents of the plist was an array or a dictionary?
>>>> 
>>>> Thanks in advance.
>>>> Alex Zavatone
>>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/gerti-cocoadev%40bitart.com
>> 
>> This email sent to gerti-cocoa...@bitart.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 Alex Zavatone via Cocoa-dev


> On May 9, 2021, at 2:15 PM, Steve Mykytyn  wrote:
> 
> You're creating your own problem here.  If you are controlling what the 
> configuration plist is, make it a dictionary at the top level with three keys 
> and entries:

Yup.  I sure am.  Creating it because I want to solve it.

It’s a flavor of my white label architecture configuration that I created when 
I rewrote SendWordNow in 2015.  The entailed moving the app into a framework 
and had a white label launcher app that read a config file based on my stuff 
from back in 1998 when I made a Director App wrapper engine and specially based 
config files.  (I need to add more meaningless buzzwords. : D )

But this needs to be a more simple case tolerant as there are several apps that 
I’m making for a client that can either start with a dictionary at the top of 
the plist or an array and I need to make it forgiving for them.



> 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.
> 

I like this.  This can handle the next stage of security which is really going 
to make people happy.

> 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.

Lots of goodness here, Steve.  Thanks for giving me the reason to explain.  And 
I can’t wait to tell the client about how we can now show that we are even more 
security aware so that the sec eval team realizes that we are adding security 
check boxes that we can check off.

Very nice.  I like this a lot.  Where should I send the check?

Cheers,
Alex Zavatone
___

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

Please do not post admin requests or moderator comments to the list.
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 Alex Zavatone via Cocoa-dev
This little write up might be a fun read.  Hey, it’s Sunday.  Why not?

> On May 9, 2021, at 4:27 PM, Sandor Szatmari  
> wrote:
> 
> 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

Thanks Sandor.  What’s awesome about this list is just how many collective 
brain cells we all have with all of the experience here.  It’s probably worth a 
little explanation and the end result might actually be a little fun (did I say 
it’s fun? Because it’s fun.) example of my rumored white label approach and a 
very very lightweight example of config based app architecture that supports 
this white label thingie.

It’s actually for clients who say “we are codey” but really aren’t in the way 
that they need to be.  They are solid, they are smart.  But not as Xcode 
engineers and that’s why my crew is here.  I’m creating a standard flavor of 
two config file types that will let them use to create new apps.  They are 
really good people and have a clue, but based on my experience, I need to over 
plan to make sure things are handled predictably.

We made a little app engine that they can adjust and tweak.  Some of the apps 
are using array data structures and other are using dictionary ones because the 
main screen has different navigation methods to load data that they can click 
on.

The apps need to be able to be duplicated, republished and tweaked.  My 
architecture is to map the name of the app to the name of a folder reference 
that automatically lists all files dropped into its folder.  It will then list 
if the expected folder and file exists and if it doesn’t, it will list what’s 
there.

In the config file, this is what is read and what populates the main screen’s 
nav item and when selected, the tapped on index is what is displayed in the 
next screen.

This allows the client to 
1. Duplicate the app and rename it.
2. Add an assets catalog with the proper items in it for icons and such.
3. Add a folder within the “App Specific Assets and Data” folder that is the 
name of their new app.
4. Add a plist to the “App Specific Assets and Data” folder : the name of their 
app : appName " - config data.plist” file.
5. Populate the plist with the data for their new app.

Run the new app and it’s all brand new.

Cool?

There will be a few parse classes based on the result of the data, but at least 
now, I can still make it generic enough to load it into the app and store it 
with the help that everyone’s shared with me today.

Cheers all!

Alex Zavatone

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


Does anyone have any experience with positioning items in an iOS UITabBar?

2021-06-04 Thread Alex Zavatone via Cocoa-dev
We’re trying to add extra space to the left and right of a UITabBar, but having 
no luck at all.

Have any of you messed with this?

Thanks in advance on any tips.
Alex Zavatone
___

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

Please do not post admin requests or moderator comments to the list.
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   >