Re: loadNibNamed deprecated, but newer version crashes

2016-09-19 Thread Dave
Yeah, you need to either assign the Array to a strong property OR you need to 
extract what you want from the Array and store those items as a strong property.

Cheers
Dave

> On 19 Sep 2016, at 11:19, Alastair Houghton  
> wrote:
> 
> On 19 Sep 2016, at 10:02, Gabriel Zachmann  wrote:
>> 
>> Thanks a lot for your response.
>> 
>> When I replace this line 
>>  [NSBundle loadNibNamed: @"ConfigureSheet" owner: self];
>> by this:
>>  NSBundle * bundle = [NSBundle bundleForClass:[self class]];
>>  [bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: 
>> nil];
>> 
>> then System preferences crashes with this stack trace:
> 
> The problem is likely that you aren’t retaining all of the top level objects 
> in the nib file, and something you’re relying on is being disposed of.  The 
> simplest fix for older code that was using the original -loadNibNamed:owner: 
> method is often just to add an NSArray member variable to your class to hold 
> the top level object references.
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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/archive%40mail-archive.com

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

Re: How to make Xcode launch a different app when "Running" my code?

2016-09-19 Thread Alastair Houghton
On 18 Sep 2016, at 14:54, Uli Kusterer  wrote:
> 
> On 18 Sep 2016, at 12:02, Gabriel Zachmann  wrote:
>> When I "Run" my code in Xcode (i.e., hit CMD-R), I would like Xcode to build 
>> the code, copy the product to its destination,
>> and then run a *different* application, not the product it has built.
>> (all on macOS, not iOS)
> 
> Sure! Pick "Edit Scheme..." from the target selection popup in your Xcode 
> window's toolbar. There, select the "Run" entry on the left. In the "Info" 
> tab, you can set the executable to run to any executable in your project, or 
> another arbitrary one. 

This is IMO the best approach, but as an addendum you probably want to think 
about whether the scheme should be shared or not.  By default, build schemes 
are per user, so if you have multiple people working on your project you’ll 
need each of them to set this up, and depending on how you’ve set your source 
control up it might also not check in per-user things in the project file (I 
know I tend to set things up so per-user stuff isn’t saved, to avoid bloating 
commits with random Xcode state that nobody else cares about).  There’s a 
“Shared” checkbox on “Edit Scheme…” sheet for that purpose.

IMHO this is quite a confusing area, because by default Xcode auto generates 
schemes and they’ll look them same for everyone who opens a project, which 
leads people to expect that changes they make will persist for everyone else.  
That isn’t the case.

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

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

Re: Triggering a segue from code

2016-09-19 Thread Quincey Morris
On Sep 19, 2016, at 18:10 , mail...@ericgorr.net  
wrote:
> 
> The strange behavior I am now seeing is that when I show & hide the panel 
> using the buttons are what appears to be two (not three, not four, etc.) 
> different instances of the inspector panel. The autosave information only 
> appears to apply to one but not the other.

A couple of things:

1. You’re keeping the panel window instance reference in 
InspectorWindowController.sharedInstance, but not keeping a reference to its 
window controller. That causes its window controller to be deallocated early, 
although that likely has nothing to with the rest of the problem, since the 
panel doesn’t have any custom behavior yet. You should keep a reference to the 
window controller instead, and that will keep the panel alive too.

2. You’re doing a “performClose” to hide the panel. If you do an orderOut 
instead, you get the behavior you want.

Note that you are getting a new instance of the panel because the window segue 
mechanism decides the first one has disappeared. Again because it’s not 
documented how window segues work, there’s no way of knowing what the “correct” 
behavior is supposed to be. (Your panel window is correctly set to “Single” 
mode in the storyboard, which is what’s supposed to prevent multiple instances 
from appearing.)

Also undocumented — forever AFAIK although others on this list may know more 
about this — is what a window “close” (or “performClose”) does, other than 
ordering out the window and (if it’s set to release on close) to release it. 
Whatever a “close” actually does, it’s making the storyboard mechanism unable 
to find the panel instance, so it creates a new one. (Your panel is *not* set 
to release on close, and I was able to verify that it’s not being released 
regardless, so this is not anything you appear to be doing wrong.)

___

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

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

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

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

Re: loadNibNamed deprecated, but newer version crashes

2016-09-19 Thread Gabriel Zachmann
Thanks a lot for your response.

When I replace this line 
[NSBundle loadNibNamed: @"ConfigureSheet" owner: self];
by this:
NSBundle * bundle = [NSBundle bundleForClass:[self class]];
[bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: 
nil];

then System preferences crashes with this stack trace:

Exception Type:EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:   KERN_INVALID_ADDRESS at 0x07fe17f0b260
0   libobjc.A.dylib 0x00010c0434dd objc_msgSend + 29
1   com.apple.ScreenSaver   0x000122308df2 -[ScreenSaverView 
_oneStep:] + 98
2   com.apple.Foundation0x00010baecb4e 
__NSFireDelayedPerform + 377
3   com.apple.CoreFoundation0x00010da0bb94 
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
4   com.apple.CoreFoundation0x00010da0b823 __CFRunLoopDoTimer + 
1075
5   com.apple.CoreFoundation0x00010da0b37a __CFRunLoopDoTimers 
+ 298
6   com.apple.CoreFoundation0x00010da02871 __CFRunLoopRun + 1841

So, it seems like the init function  initWithFrame:isPreview:  in my subclass 
of ScreenSaverView finishes fine,
only when ScreenSaverView tries to perform one animation step, it crashes.
I think, at this point, it has not yet called my code to perform an animation 
step.

There is no more info in the system.log.


Best regards, 
Gabriel.


___

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

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

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

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

Strange UIWebView issue after upgrading to Xcode8

2016-09-19 Thread Diederik Meijer
Dear list,

In my app I have a horizontal UIStackView that has three UIViews, each of which 
has a UIWebView.

The UIStackView is embedded in a UIScrollView. The scrollView’s frame equals 
the viewController’s view’s frame, its content size is three times the 
viewController’s view’s width.

This operates as an infinite carousel for text content.

The whole view hierarchy is created in IB and uses auto layout. Platform is 
iOS, source code used Objective-C and Swift 2.3.

The problem I have is that when the user rotates the device, the UIWebViews 
embedded in the UIStackView don’t fill their entire size.

A part of the right hand side of the UIWebViews is not used/filled by the 
UIWebView, instead it is revealing the UIWebView’s superView.

The size of this unused part increases with every subsequent rotation.

I have tested the frame size width for both the UIWebView and its scrollView in 
the didRotateFromInterfaceOrientation function, those numbers are fine and 
stable, they don’t change no matter how many times I rotate the device. This 
suggests that auto layout is working as expected.

So while both these width parameters keep returning 634.5 for landscape 
orientation and 447.5 for portrait orientation, the webView’s visible content 
size is shrinking a little bit with every rotation.

I have tried various suggestions found on Stackoverflow, even adding a viewport 
metatag with the correct width before reloading the web view’s content after 
each rotation.

None of these seem to fix this issue.

Has anybody here run into this issue and are there any pointers towards a 
solution?


Many thanks,



Diederik


___

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

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

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

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

Re: loadNibNamed deprecated, but newer version crashes

2016-09-19 Thread Alastair Houghton
On 19 Sep 2016, at 10:02, Gabriel Zachmann  wrote:
> 
> Thanks a lot for your response.
> 
> When I replace this line 
>   [NSBundle loadNibNamed: @"ConfigureSheet" owner: self];
> by this:
>   NSBundle * bundle = [NSBundle bundleForClass:[self class]];
>   [bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: 
> nil];
> 
> then System preferences crashes with this stack trace:

The problem is likely that you aren’t retaining all of the top level objects in 
the nib file, and something you’re relying on is being disposed of.  The 
simplest fix for older code that was using the original -loadNibNamed:owner: 
method is often just to add an NSArray member variable to your class to hold 
the top level object references.

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

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

Xcode-like title bar using title bar accessory view

2016-09-19 Thread David Catmull
I'm trying to create a title bar resembling Xcode's, where toolbar-like
controls replace the standard window title in the area to the right of the
standard 3 buttons.

So far, I've added a title bar accessory view and set the window's
titleVisibility to hidden. But the results aren't quite right.

If my accessory view uses the default layoutAttribute value of .bottom,
then my accessory view appears below the standard window controls as if it
were a toolbar.

If I set the layoutAttribute to .right, then the accessory view appears up
in place of the title where I want it, except the title bar isn't tall
enough and the bottom gets cut off. Also, the accessory view is pinned to
the right, and doesn't resize horizontally with the window (as it does with
.bottom). Similarly with .left.

So how to I get my title bar accessory view to:
- Appear to the right of the standard window buttons
- Always fill the remaining width of the title bar
- Get enough vertical space
___

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

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

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

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

Re: Package installation on MacOS Sierra

2016-09-19 Thread James Walker

On 9/18/2016 3:36 PM, Graham Cox wrote:

I have the classic .dmg approach to installation, where a disk image
includes an alias for /Applications and the user drags the app icon to
it. On 10.12, the alias appears to point to nothing, and has a generic
file icon.


The disk image should contain a symbolic link to /Applications, which 
looks like an alias but is a different animal.  An alias contains more 
information, and might be trying too hard to match a *specific* 
Applications folder.


___

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

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

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

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

Re: Triggering a segue from code

2016-09-19 Thread mail...@ericgorr.net
Thank you for your reply Quincey. I am definitely getting closer to the 
behavior I want. 

Performing the “Show Inspector” segue from the my custom document window 
controller (WindowController.swift) allows both by regular button and toolbar 
button to show the Inspector.

As you suggested, I also created a  custom window controller for my inspector 
(InspectorWindowController.swift). It looks like:

class InspectorWindowController: NSWindowController
{
static var sharedInstance: NSWindow? = nil

override func windowDidLoad()
{
super.windowDidLoad()

InspectorWindowController.sharedInstance = self.window
}
}

This does allow my hide panel action function to hide the panel by doing:

@IBAction func hideMyPanel( _ sender: AnyObject )
{
InspectorWindowController.sharedInstance?.performClose( self )
}


The strange behavior I am now seeing is that when I show & hide the panel using 
the buttons are what appears to be two (not three, not four, etc.) different 
instances of the inspector panel. The autosave information only appears to 
apply to one but not the other.

I have updated the project which should replicate this behavior.

If you or anyone else has any ideas on how I can get the correct behavior for 
showing and hiding the inspector NSPanel, I would be interested.


> On Sep 18, 2016, at 4:32 PM, Quincey Morris 
>  wrote:
> 
> On Sep 18, 2016, at 12:22 , mail...@ericgorr.net 
>  wrote:
>> 
>> While I do see the log message 'How do I..', my utility panel is not shown.
>> 
>> How can I get this work?
> 
> Most of the problem is that storyboards and segues for the Mac are 
> inadequately documented. This is exacerbated by the fact that understanding 
> the behavior “by analogy with iOS” breaks down when windows are involved, 
> since there’s no such thing (AFAIK) as a segue between windows on iOS.
> 
> By trial and error, I discovered that the problem in your sample project is 
> that a “show” segue from a view controller does not open a new window. This 
> halfway makes sense, although the fact that it does nothing and produces no 
> exception or log message is pretty unhelpful. (Bug report!)
> 
> To get the button to display the panel, you need to have the window 
> controller perform the segue. That means you’ll need a custom window 
> controller subclass for the main window, and you can just move the action 
> method into the window controller. (Hook the button up to First Responder 
> instead of the view controller, too.)
> 
> Alternatively, go back to using a segue from the button to open the panel, 
> which IIRC was working in an earlier version of this test project. (You 
> posted that it wasn’t working, but when I went to look at your project you’d 
> already fixed the problem in your project that was preventing it from 
> working. IIRC.)
> 
> To do all the combinations of hiding and showing a singleton panel, you’ll 
> probably want another custom window controller subclass for the panel itself. 
> Not every window/window controller operation seems to be mapped into 
> storyboard semantics, so you should expect that there are things that still 
> need to be done “the old way”.
> 

___

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

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

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

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