didPrint selector not called

2016-12-16 Thread Jeremy Hughes
Hi, I’m overriding printDocumentWithSettings in order to get a notification for when printing has finished, but the didPrint selector is never called. This is the code: class func document(document: NSDocument, didPrint: Bool, contextInfo: UnsafeMutablePointer) { print("document was pr

Fwd: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
Sorry - I forgot to copy to the list. Jeremy -- > Begin forwarded message: > > From: Jeremy Hughes > Subject: Re: didPrint selector not called > Date: 16 December 2016 at 19:15:10 GMT > To: John McCall > >> On 16 Dec 2016, at 17:24, John McCall wrote: >>

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
can call through to. I suppose it would apply if I had a subclass (of my document class) that needed to override the callback. Does that seem right to you? Jeremy -- > On 16 Dec 2016, at 18:26, Quincey Morris > wrote: > > On Dec 16, 2016, at 08:45 , Jeremy Hughes wrote: >>

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> On 16 Dec 2016, at 19:29, John McCall wrote: > >> On Dec 16, 2016, at 11:24 AM, Jeremy Hughes >> wrote: >> Thanks for the link. >> >> I’ve looked at it, and I don’t think it applies in this case, because I’m >> not actually overriding the docu

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
Also, NSInvocation (used in the release notes sample code) is unavailable in Swift. Jeremy -- > On 16 Dec 2016, at 19:33, Jeremy Hughes wrote: > >> >> On 16 Dec 2016, at 19:29, John McCall wrote: >> >>> On Dec 16, 2016, at 11:24 AM, Jeremy Hughes &

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
>> OK - I misunderstood what Quincey was saying. >> >> The passed-in delegate and selector are nil, but I obviously can’t be sure >> that they will always be nil. >> >> All I’m actually trying to do is to clean up some objects that need to exist >> during the print operation. Is this the best w

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> On 16 Dec 2016, at 20:01, Jeremy Hughes wrote: > >>> OK - I misunderstood what Quincey was saying. >>> >>> The passed-in delegate and selector are nil, but I obviously can’t be sure >>> that they will always be nil. >>> >>> Al

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> On 16 Dec 2016, at 20:17, Jeremy Hughes wrote: >>> I'm not an expert in this part of Cocoa. Are there implicit system >>> *callers* of this method, or is it more of a system *utility* that you're >>> expected to call from your own code? If it&

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> This is what I’ve currently got. It works OK, but the dictionary conversion > seems clunky to me. > > override func printDocument(sender: AnyObject?) > { > let didPrintSelector = #selector(document(_:didPrint:contextInfo:)) > > let dictionary = printInfo.dictionary() >

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> On 16 Dec 2016, at 21:40, Quincey Morris > wrote: > > On Dec 16, 2016, at 12:01 , Jeremy Hughes wrote: >> >> It’s just an application method, which overrides the method that the system >> calls from printDocument when a user chooses Print. > > Jus

Re: didPrint selector not called

2016-12-16 Thread Jeremy Hughes
> On 16 Dec 2016, at 21:54, Jeremy Hughes wrote: > >> In that case, you don’t know for sure who calls it and when. It appears to >> documented that it’s called as part of the standard implementation of >> “printDocument”, but you don’t know if there are other circ

Re: Overwhelming Options

2011-09-02 Thread Jeremy Hughes
Quincey Morris (1/9/11, 21:42) said: >If it should happen that there was a practical need to change the column >display frequently (dozens of times per day), choosing individual >columns from a context menu would get very old very fast. In that case, >the only practical choice might be an array of

Re: devil of a time with an NSImageView

2009-08-21 Thread Jeremy Hughes
Quincey Morris (20/8/09, 19:31) said: >On Aug 20, 2009, at 11:02, I. Savant wrote: > >> I missed that thread. Do you happen to know some keywords from the >> subject? > >No, I've looked for it but I can't find it. It was one of a number of >similar questions around that time, possibly about iPhon

Re: Dismissing Open dlog before doc actually opens

2013-08-14 Thread Jeremy Hughes
Graham Cox (14/8/13, 06:51) said: >They did, which is why first modeless dialogs (from System 1? 2?) and >then sheets (OSX 1.0) were developed. Even as far back as the original >Inside Macintosh the use of modal dialogs was strongly discouraged when >it was possible to use something else. The orig

Binding NSTextField to an array

2017-03-06 Thread Jeremy Hughes
Hi, This seems like an elementary question. I’d like to bind an NSTextField to an array of numerical values, so that the text field will either display a single value if the values are identical or will display a multiple values marker if the values are different. Using Swift, I can bind a tex

Re: Binding NSTextField to an array

2017-03-06 Thread Jeremy Hughes
> From what I understand of your example, you’re not “binding” anything in a > Cocoa sense. In the case of the single value, the text field is set up via the Bindings pane of Interface Builder so that “Value" says “Bind to File’s Owner” with a model key path of self.value. (And “value" is decla

Re: Binding NSTextField to an array

2017-03-06 Thread Jeremy Hughes
> On 6 Mar 2017, at 14:30, Jonathan Mitchell wrote: > > Sounds like NSValueTransformer is in fact what you need. > It can take in your NSArray ref and spit out a single NSString that the > NSTextField binding can live with. I think I must be missing something obvious. The value of an NSTextFie

Re: Binding NSTextField to an array

2017-03-06 Thread Jeremy Hughes
ection to > generate values from. > > Mike. > >> On 6 Mar 2017, at 17:44, Jeremy Hughes wrote: >> >>> On 6 Mar 2017, at 14:30, Jonathan Mitchell wrote: >>> >>> Sounds like NSValueTransformer is in fact what you need. >>> It can take

Re: Binding NSTextField to an array

2017-03-06 Thread Jeremy Hughes
> On 6 Mar 2017, at 17:34, Jeremy Hughes wrote: > > It all works now. Actually, it works as far as the text field displays “Multiple” (placeholder) for multiple values, but it doesn’t work when I set a value in the text field. In that case I get: Error setting value for

needsDisplay and subviews

2017-03-08 Thread Jeremy Hughes
If needsDisplay is set to true for an NSView, does that also cause subviews to be redrawn? I’ve seen conflicting statements about this, but haven’t found anything in Apple’s documentation. Jeremy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.co

Re: needsDisplay and subviews

2017-03-08 Thread Jeremy Hughes
drawn - except when “wantsLayer” has been set to true. Does that make sense? Jeremy -- > On 8 Mar 2017, at 17:12, Jeremy Hughes wrote: > > Thanks - that seems reasonably clear, and it agrees with what I previously > thought, but I’ve got a situation where it doesn’t see

Re: needsDisplay and subviews

2017-03-09 Thread Jeremy Hughes
> On 9 Mar 2017, at 01:49, Quincey Morris > wrote: > > So, the correct answer to your original question, I think, is that if your > model data has changed in such a way that the representation in custom views > no longer reflects the data, then you should set “needsDisplay” on *every* > custo

Re: needsDisplay and subviews

2017-03-09 Thread Jeremy Hughes
> On 9 Mar 2017, at 10:24, Jeremy Hughes wrote: > > So it seems that for layer-backed views, setting needsDisplay does cause the > view to be redrawn - but the value is never actually set. If I needed to work > with layer-backed views, it might be possible to get around this b

Re: needsDisplay and subviews

2017-03-10 Thread Jeremy Hughes
> On 9 Mar 2017, at 18:32, corbin dunn wrote: > >> >> On Mar 8, 2017, at 8:46 AM, Jeremy Hughes >> wrote: >> >> If needsDisplay is set to true for an NSView, does that also cause subviews >> to be redrawn? >> >> I’ve seen conflictin

Calculating intrinsicContentSize for a NSTextField

2017-03-17 Thread Jeremy Hughes
I have a text field that I want to grow and shrink while it is being edited. In order to do that, I have overridden intrinsicContentSize and textDidChange in a subclass of NSTextField: override var intrinsicContentSize: NSSize { if let cell = cell, cell.wraps

Re: Calculating intrinsicContentSize for a NSTextField

2017-03-18 Thread Jeremy Hughes
> On 18 Mar 2017, at 04:45, Daryle Walker wrote: > >> This works, but if I remove the call to attributedStringValue (whose result >> is discarded) the result of the following line fails to reflect changes in >> the bounds of the text, and the field fails to grow or shrink. >> >> Presumably, ca

Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
I’m trying to understand who owns a child view controller after it has been removed from its parent view controller. The following code (which doesn’t involve view controllers) behaves as I would expect: import Cocoa class Element { var children = [Element]() weak var parent: E

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 17:41, Jens Alfke wrote: > > There may still be a reference in the autorelease pool. Check childReference > again ‘later’, i.e. on the next user event or after a timer/delayed-perform. Thanks. I’d forgotten about autorelease pools - but I guess they’re still there in Coco

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 18:38, Charles Srstka wrote: > >> On Jul 12, 2017, at 12:23 PM, Jens Alfke wrote: >> >>> On Jul 12, 2017, at 9:54 AM, Jeremy Hughes >>> wrote: >>> >>> I’d forgotten about autorelease pools - but I guess they’re stil

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 19:25, Jens Alfke wrote: > >> >> On Jul 12, 2017, at 10:57 AM, Jeremy Hughes >> wrote: >> >> Wouldn’t it be ARC (rather than the consumer) that is balancing retains? > > Yes. ARC internally generates calls to -autorelease

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 19:24, Jens Alfke wrote: > >> While that’s true, the main reason, as I understand it, that ARC doesn’t >> know enough about the object’s lifetime is that non-ARC code may be calling >> the method. In an all-ARC world, a method could always just return objects >> with a +1

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
Thanks for elucidating! > On 12 Jul 2017, at 22:03, Greg Parker wrote: > > ARC does add an optimization where a cooperating caller and callee can safely > avoid the retain/release pair around the return operation, effectively > transforming that call into the return-retained convention. So in

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 22:07, Quincey Morris > wrote: > >> Or there's something else going on under the covers. > > Yes, you are correct, betting *against* this assumption is a really, really > terrible idea. Reasoning about the point at which objects actually deallocate > is a code smell. I’m

Re: Who owns a child view controller?

2017-07-12 Thread Jeremy Hughes
> On 12 Jul 2017, at 23:18, Doug Hill wrote: > > While this discussion has been good at understanding underlying ARC and > manual ref-count issues, my guess as to what's causing these issues is that > you shouldn't just assign nil to the childViewControllers array. Actually an empty array rat

Re: Who owns a child view controller?

2017-07-13 Thread Jeremy Hughes
> On 13 Jul 2017, at 01:32, Jens Alfke wrote: > >> On Jul 12, 2017, at 2:57 PM, Jeremy Hughes >> wrote: >> >> I’m trying to understand memory management so I can avoid retain cycles and >> other issues. > > That’s fine. But using a weak refe

Re: Who owns a child view controller?

2017-07-13 Thread Jeremy Hughes
> On 13 Jul 2017, at 10:57, Jeremy Hughes wrote: > > Apple’s Swift book says: > > "The examples above show how to use safe unowned references. Swift also > provides unsafe unowned references for cases where you need to disable > runtime safety checks—for example, f

Re: Who owns a child view controller?

2017-07-13 Thread Jeremy Hughes
> On 13 Jul 2017, at 11:26, Jeremy Hughes wrote: > > So perhaps the difference between safe and unsafe unowned is that safe > unowned generates a runtime error (but doesn’t crash) while unsafe unowned > crashes? Or perhaps they both crash, but unowned(unsafe) gives a more h

Re: Who owns a child view controller?

2017-07-14 Thread Jeremy Hughes
> On 13 Jul 2017, at 19:43, Quincey Morris > wrote: > > Here’s how I understand the situation in Swift. As usual, I may have some > things a bit wrong, but I think this is right. There are four kinds of > reference variable (or stored property) in Swift: > > 1. Strong. > > 2. Weak. > > 3. U

Re: Who owns a child view controller?

2017-07-14 Thread Jeremy Hughes
> On 12 Jul 2017, at 17:41, Jens Alfke wrote: > >> On Jul 12, 2017, at 9:34 AM, Jeremy Hughes >> wrote: >> >> // Prints "Why is childReference not nil?” > > There may still be a reference in the autorelease pool. Check childReference > again ‘la

Re: Who owns a child view controller?

2017-07-14 Thread Jeremy Hughes
> On 13 Jul 2017, at 20:29, Alex Zavatone wrote: > > One thing that I had to learn was to break my expectations of when a view > controller (one that is tied to a navigationController) is deallocated. I’m not sure that view controllers are special. My understanding is that objects that are in

Re: Who owns a child view controller?

2017-07-14 Thread Jeremy Hughes
> On 14 Jul 2017, at 14:40, Steve Christensen wrote: > > On Jul 14, 2017, at 3:50 AM, Jeremy Hughes > wrote: >> >> I’m still not entirely clear on when autorelease pools are used in Swift. >> There is a WWDC video which says that they’re used in code that interf

Re: Is "-init" really needed?

2017-08-10 Thread Jeremy Hughes
> On 10 Aug 2017, at 15:15, Alastair Houghton > wrote: > > On 10 Aug 2017, at 15:09, Charles Srstka wrote: >> >> They’re equivalent syntactically, but performance-wise, +array and friends >> will cause the object to be put into an autorelease pool. Therefore, +new is >> better for performanc

10.13 printing problem

2017-12-19 Thread Jeremy Hughes
I have a problem printing an autolayout view in 10.13.2, and I’m wondering if there is something wrong with my code or if Apple broke something in 10.13 or a more recent update. I’m using the same view class for printing and screen, but I have a separate view object for printing. I’m overridin

Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
The release notes for 10.13 say: If your application is linked on macOS 10.13 SDK or later, classes that return NSPasteboardReadingAsKeyedArchive from readingOptionsForType:pasteboard: must support secure coding, and will be decoded with a coder that requires secure coding. So I’m updating som

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
lizer, right? Jeremy -- > On 20 Dec 2017, at 01:09, Jeremy Hughes wrote: > > The release notes for 10.13 say: > > If your application is linked on macOS 10.13 SDK or later, classes that > return NSPasteboardReadingAsKeyedArchive from > readingOptionsForType:pasteboard:

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
Thanks, Quincey. > That looks like Swift 3 code. The current version of the function is like > this: > >> @nonobjc func decodeObject(of classes: [AnyClass]?, forKey key: String) -> >> Any? @nonobjc means this is Swift-specfic then? The init function I’m using is marked as @objc: @objc requir

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 01:25, Quincey Morris > wrote: > > You’ll have to figure out what type to use for the Ints. If they were > actually saved compatibly with Obj-C, the Ints will actually be NSNumbers, > and you’ll need to say “NSNumber.self”. If the Ints are stored opaquely as > Ints, I gue

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 02:07, Quincey Morris > wrote: > > The class must be a kind of AnyClass, so you can’t specify a struct type. > Sorry I sent you off in the wrong direction on that. That’s what I just concluded in an email I started writing. >> The code I mentioned in my follow-up email se

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 02:22, Jeremy Hughes wrote: > > What I don’t like about [NSArray.self] is that it’s an artefact of bridging. > I’m not actually using it in the encoder: > > coder.encode(arrayOfInts, forKey: kArrayKey) The declaration: encode(_ object: Any?, forKey key:

Re: 10.13 printing problem

2017-12-19 Thread Jeremy Hughes
> On 19 Dec 2017, at 18:03, Jeremy Hughes wrote: > > I have a problem printing an autolayout view in 10.13.2, and I’m wondering if > there is something wrong with my code or if Apple broke something in 10.13 or > a more recent update. > > I’m using the same view class fo

Re: Pasteboards and NSSecureCoding

2017-12-20 Thread Jeremy Hughes
eremy -- > On 20 Dec 2017, at 05:03, Quincey Morris > wrote: > > On Dec 19, 2017, at 18:32 , Jeremy Hughes wrote: >> >>> On 20 Dec 2017, at 02:22, Jeremy Hughes wrote: >>> >>> What I don’t like about [NSArray.self] is that it’s an artefact of >

Scroll views

2018-01-19 Thread Jeremy Hughes
Does anyone understand scroll views? I struggle every time I use them, and it seems that I have to go through a process of trial and error to get them working properly. If I drag a scroll view into another view in Interface Builder, I get a “Bordered Scroll View” that contains a “Clip View” tha

Scroll views and autolayout

2018-01-19 Thread Jeremy Hughes
This is a follow-up to my previous email on Scroll views. What I actually want to is be able to swap different views (with different heights) in and out of the scroll view. To do this, I’m adding the different views as a subview of the “document" view (called contentParent below): contentParent

Re: Scroll views

2018-01-19 Thread Jeremy Hughes
> On 19 Jan 2018, at 22:15, Quincey Morris > wrote: > >> Interface Builder complains if I don’t also add vertical constraints, so >> I’ve done that, but made the bottom constraint into a placeholder (“Remove >> at build time”). Your email suggests that I can also make the top constraint >> in

Re: Scroll views

2018-01-20 Thread Jeremy Hughes
Hi Quincey, I saw Kyle Sluder’s post some time ago, but it’s quite old and I’m not sure how relevant it is now. My complaint about scroll views is not that they don’t work, but that they’re confusing and I struggle each time I use them. My initial email was an attempt to summarise what I’ve dis

Re: Size of compiled NIBs in Xcode 9 (10.13 SDK)

2018-01-24 Thread Jeremy Hughes
I posted a related question in https://apple-dev.groups.io/g/xcode/ ("Assets.car is much larger for High Sierra builds”) but I didn’t get much in the way of a reply. It seems that Assets.car is much larger when it is built with the 10.13 SDK than when it is built with the 10.12 SDK. I don’t kn

Re: Size of compiled NIBs in Xcode 9 (10.13 SDK)

2018-01-24 Thread Jeremy Hughes
> I posted a related question in https://apple-dev.groups.io/g/xcode/ > ("Assets.car is much larger for High Sierra builds”) but I didn’t get much in > the way of a reply. https://apple-dev.groups.io/g/xcode/message/396 > It seems that Assets.car is much larger when it is built with the 10.13 S

Re: Size of compiled NIBs in Xcode 9 (10.13 SDK)

2018-01-24 Thread Jeremy Hughes
> On 24 Jan 2018, at 19:46, Dragan Milić wrote: > > BTW, in both cases (Xcode 9 - 10.13 SDK and Xcode 8 - 10.12 SDK) the > deployment target is macOS 10.11, so I don't think that setting matters. Vince has explained why it does matter. If you change the deployment target to 10.13 (which you pr

Re: Persistent User Defaults

2018-04-30 Thread Jeremy Hughes
Killing cfprefsd seems unnecessarily drastic. Why not use: defaults delete as Gary Wade mentioned earlier? is a reverse-dns string such as “com.company.appname” — > On 30 Apr 2018, at 15:31, Alex Zavatone wrote: > > Is it worth it (or wise) to zero out preferences and write them prior to

Re: Carbon -> Cocoa

2018-08-16 Thread Jeremy Hughes
We found it very difficult. This was for a large C++ Carbon application. We’re now rewriting in Swift + Cocoa, starting from scratch. Jeremy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comment

Re: Carbon -> Cocoa

2018-08-16 Thread Jeremy Hughes
> By now, Cocoa may be the new Carbon. The crucial difference is that Cocoa supports 64-bit applications, and Carbon doesn’t. > If you haven't switched to Cocoa after all these years, and if your app is > large, I'd wait to see what happens with Marzipan We don’t have time to wait for Marzipa

Re: Carbon -> Cocoa

2018-08-17 Thread Jeremy Hughes
> Our app has 6 or 8 programmer-years of C++ cross-platform business logic. > Accounting software is complicated. Rewriting that in another language would > be hard work, and tons of testing. More than Mac sales would justify, so it > would be time to go Windows-only or just fold. If you have

Re: Carbon -> Cocoa

2018-08-17 Thread Jeremy Hughes
> Of course, the C++ business logic doesn't need any changes. The concern is, > how long will it last? Seems like the future is an entirely Swift-based API > that replaces Objective-C Cocoa in 5 years, with no easy way to link to other > languages. Core parts of Webkit are written in C++, so I

Re: printing black

2019-01-22 Thread Jeremy Hughes
> On 22 Jan 2019, at 18:23, Alastair Houghton > wrote: > > There’s often a printer setting on users’ printers to tell them to use (just) > black ink. This also shows up in Cocoa Print dialogs under “Printer features” or as a “Greyscale” checkbox. I have it turned on by default. Jeremy _

Re: Thoughts on Cocoa

2019-10-04 Thread Jeremy Hughes via Cocoa-dev
Hi Jens, > On 3 Oct 2019, at 20:04, Jens Alfke via Cocoa-dev > wrote: > > The people I hear complaining about this are those who, like you, didn't move > to Cocoa. Carbon was a _temporary_ transition API*. It wasn’t clear to us (outside Apple) that Carbon was a temporary API until 2007, whe

Re: Thoughts on Cocoa

2019-10-04 Thread Jeremy Hughes via Cocoa-dev
> On 4 Oct 2019, at 11:43, Dragan Milić via Cocoa-dev > wrote: > >> pet 04.10. 2019., at 11.51, Jeremy Hughes via Cocoa-dev wrote: >> >> It wasn’t clear to us (outside Apple) that Carbon was a temporary API until >> 2007, when Apple suddenly abandoned 64-bit C

Re: Need for Swift

2019-10-15 Thread Jeremy Hughes via Cocoa-dev
Maybe it’s also worth noting that WebKit (the browser engine used by Safari) is written in C++ Safari’s UI is probably written in Obj-C(++) or a mixture of Obj-C(++) and Swift. Jeremy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do

Re: Need for Swift

2019-10-15 Thread Jeremy Hughes via Cocoa-dev
> On 15 Oct 2019, at 18:27, Turtle Creek Software via Cocoa-dev > wrote: > > MVC is an excellent design paradigm. The M and V layers were no problem at > all to set up. The C started out easy, but ended up being a big problem. > Quite a bit of the business logic is not just data, but fancy stuf