Re: sharing code between screensaver and regular app

2020-03-02 Thread Jonathan Prescott via Cocoa-dev
When you created the application, you should have created two pairs of files, 
AppDelegate.h/.m and ViewController.h/.m.  The AppDelegate is used to augment 
and tailor the behavior of the NSApplication that is implicitly created as part 
of the AppKit framework.  For your purposes, you may not need to implement this 
code (however, you should look at the AppDelegate documentation to make sure).  
The ViewController is derived from NSViewController, and is the container for 
your screen saver view (which is probably derived from ScreenSaverView, which 
is derived from NSView).  An instance of this view is a property of your 
ViewController.

If you look back at the link you referred to, you’ll see that is creating a 
ViewController that will be a container for you screen saver view.  Although 
it’s in Swift, it should be straightforward to translate back into Objective-C

Jonathan
___

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

Please do not post admin requests or moderator comments to the list.
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: Sharing code between screensaver and regular app

2020-03-02 Thread Dave via Cocoa-dev
Hi,

All I can think of that this behaviour has changed on your version of 
MacOS/XCode.

You can do the same thing as the template by manually adding the files, e.g 
copy your “ViewController” file, rename it and then add it to the new project. 
You will need to make sure that the Storyboard/Nibs are the same too. Ether add 
the elements needed yourself or copy the existing storyboard/nib(s) rename and 
add to the new project. 

All the Best
Dave

> On 2 Mar 2020, at 12:36, Gabriel Zachmann  wrote:
> 
> Thanks a lot for your response!
> 
>> 
>> File/New Project - Select MacOS and then “App” (from the New Project Dialog).
> 
> That is what I did: see this screen recording:
> 
> https://owncloud.informatik.uni-bremen.de/index.php/s/br8rN3HGYfj9w3d 
> 
> 
> Still I get this boilerplate code
> 
> 
>   @interface AppDelegate : NSObject 
> 
>   @end
> 
> 
> No NSView.
> 
> 
> 
> 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: Sharing code between screensaver and regular app

2020-03-02 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot for your response!

> 
> File/New Project - Select MacOS and then “App” (from the New Project Dialog).

That is what I did: see this screen recording:

https://owncloud.informatik.uni-bremen.de/index.php/s/br8rN3HGYfj9w3d 


Still I get this boilerplate code


  @interface AppDelegate : NSObject 

  @end


No NSView.



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: Sharing code between screensaver and regular app

2020-03-02 Thread Dave via Cocoa-dev
Hi,

You need to create a project with the right template to start with. In XCode:

File/New Project - Select MacOS and then “App” (from the New Project Dialog).

On XCode 11.0 and MacOS 10.14.6, this results in a new project Setup with a 
view controller.


There are a number of ways to share code between Apps.

I usually have a folder structure like this:

CommonSource
ScreenSaver
StandaloneApp

Put the code that is common between the two into “CommonSource” and the App 
Specific Stuff into either “ScreenSaver” or “StandaloneApp”. Then add the 
common files to both projects and compile as normal.

All the Best
Dave


> On 1 Mar 2020, at 23:26, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> I am trying to replicate what this guy suggests:
>   
> https://medium.com/better-programming/how-to-make-a-custom-screensaver-for-mac-os-x-7e1650c13bd8
> under section "Additional Debugging".
> 
> The idea is to create a standalone app that shares as much code with the 
> screensaver as possible.
> 
> I am using Xcode 11, macOS Catalina, Objective-C.
> 
> Now, I have created a new project as "App".
> But, unlike on the web page, Xcode has not created an NSViewController, but 
> instead an NSObject:
> the .h-file contains 
> 
>@interface AppDelegate : NSObject 
> 
>@end
> 
> 
> Could some kind should please shed light on what to do to make my 
> ScreenSaverView a subview of the new stand-alone 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/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