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

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

Re: loadNibNamed deprecated, but newer version crashes

2016-09-18 Thread Charles Srstka
What’s the crash? Is it an exception? If so, what’s the description that gets 
posted to the console?

Charles

> On Sep 18, 2016, at 6:35 PM, Gabriel Zachmann  wrote:
> 
> I would like to replace this line of code:
>   [NSBundle loadNibNamed: @"ConfigureSheet" owner: self];
> 
> by the newer version loadNibNamed: owner:topLevelObjects:.
> 
> This runs in a screensaver. The deprecated version (loadNibNamed:owner:) 
> works.
> The new version causes a crash.
> Here are the variants I have tried:
> 
> 1.
> 
> NSBundle * bundle = [NSBundle bundleForClass:[self class]];
> NSArray * nibArray = nil;
> [bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: 
> ];
> 
> 2.
> 
> NSBundle * bundle = [NSBundle bundleForClass:[self class]];
> [bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: nil;
> 
> 3.
> 
> [[NSBundle mainBundle] loadNibNamed: @"ConfigureSheet" owner: self 
> topLevelObjects: nil];
> 
> 
> 
> I must be missing something.
> 
> I have checked the API docs, but I didn't see any hints. I have googled 
> extensively, to no avail.
> 
> Any hints, pointers, suggestions 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/cocoadev%40charlessoft.com
> 
> This email sent to cocoa...@charlessoft.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

loadNibNamed deprecated, but newer version crashes

2016-09-18 Thread Gabriel Zachmann
I would like to replace this line of code:
[NSBundle loadNibNamed: @"ConfigureSheet" owner: self];

by the newer version loadNibNamed: owner:topLevelObjects:.

This runs in a screensaver. The deprecated version (loadNibNamed:owner:) works.
The new version causes a crash.
Here are the variants I have tried:

1.

NSBundle * bundle = [NSBundle bundleForClass:[self class]];
NSArray * nibArray = nil;
[bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: ];

2.

NSBundle * bundle = [NSBundle bundleForClass:[self class]];
[bundle loadNibNamed: @"ConfigureSheet" owner: self topLevelObjects: nil;

3.

[[NSBundle mainBundle] loadNibNamed: @"ConfigureSheet" owner: self 
topLevelObjects: nil];



I must be missing something.

I have checked the API docs, but I didn't see any hints. I have googled 
extensively, to no avail.

Any hints, pointers, suggestions 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/archive%40mail-archive.com

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