New Newbie Question :-(


Charles Phillips
 

Ok next question - this should be obvious but has stopped me.

First I am running Objective-C applications (simple ones so far) as command line applications. So I have the syntax figured out, etc. I can also compile my earlier C and C++ code easily with my Objective-C code. So far my applications output to the console and output files.

But I cannot get a simple GUI application to build. 

In VeiwController.h, XCode still says that it cannot find UIKit!  I have a line: 

#import <UIKit/UIKit.h>

and I tried replacing the <> with quotes as well. But it says that 'UIKit/IUKit.h' are not found. Does the single quote tell me something?

I started this project by telling XCode that I am doing a single view MacOS application with Objective-C. That gave me UIKIt but there is not a UIKit.h file, but I also import Cocoa and I do not see a Cocoa.h file in the file structure. 

I cannot imagine that UIKit is specific to iPhone and that there is some equivalent for MacOS. All of the examples in the book are for iPhones of course. 

Charles

 


Steve Mills
 

On May 18, 2020, at 14:00:43, Charles Phillips <phillipstriples@att.net> wrote:

In VeiwController.h, XCode still says that it cannot find UIKit! I have a line:

#import <UIKit/UIKit.h>
UIKit (and anything else that begins with UI) is for iOS, not macOS. You probably want to use AppKit instead, which *is* the macOS framework that includes user interface stuff.

--
Steve Mills
Drummer, Mac geek


Jack Brindle
 

When you create a new Mac project, be sure to select macOS templates in the tab bar. There are no “Single-View” Mac templates, which indicates you actually created an iOS project.

Create a new one, this time from the macOS selection.

Also, UIKit is the iOS UI APIs. For the Mac, we use AppKit. You will be working with windows and views for the Mac, while iOS uses views.

Jack


On May 18, 2020, at 12:00 PM, Charles Phillips <phillipstriples@...> wrote:

Ok next question - this should be obvious but has stopped me.

First I am running Objective-C applications (simple ones so far) as command line applications. So I have the syntax figured out, etc. I can also compile my earlier C and C++ code easily with my Objective-C code. So far my applications output to the console and output files.

But I cannot get a simple GUI application to build. 

In VeiwController.h, XCode still says that it cannot find UIKit!  I have a line: 

#import <UIKit/UIKit.h>

and I tried replacing the <> with quotes as well. But it says that 'UIKit/IUKit.h' are not found. Does the single quote tell me something?

I started this project by telling XCode that I am doing a single view MacOS application with Objective-C. That gave me UIKIt but there is not a UIKit.h file, but I also import Cocoa and I do not see a Cocoa.h file in the file structure. 

I cannot imagine that UIKit is specific to iPhone and that there is some equivalent for MacOS. All of the examples in the book are for iPhones of course. 

Charles
 


Charles Phillips
 

Ok, next dumb question. AppKit does work, thanks. 

In the Objective-C book, it says to use this code:

@property (nonatomic) IBOutlet UILabel *nameLabel;

but it of course does not work. Since UI... is for iOS, I tried:

@property (nonatomic) IBOutlet IBLabel *nameLabel;

but that gives an error also. What is the equivalent for MacOS?

Charles


Sandor Szatmari
 

Charles,

UI is the prefix for IOS classes.  

macOS frameworks us classes derived from NSObject and most are prefixed with NS…

Sandor

On May 18, 2020, at 17:20, Charles Phillips <phillipstriples@...> wrote:

Ok, next dumb question. AppKit does work, thanks. 

In the Objective-C book, it says to use this code:

@property (nonatomic) IBOutlet UILabel *nameLabel;

but it of course does not work. Since UI... is for iOS, I tried:

@property (nonatomic) IBOutlet IBLabel *nameLabel;

but that gives an error also. What is the equivalent for MacOS?

Charles


Jack Brindle
 

There are pretty big differences between iOS and macOS, not just in frameworks, but in application design philosophy as well. I would highly recommend finding a copy of the Fourth Edition of “Cocoa Programming For Mac OS X” by Hillegas and Preble. The Fourth Edition was the last to use Objective-C, the Fifth Edition used Swift.

If you are doing Mac applications, run away as fast as you can from iOS until you fully understand the Mac platform. Otherwise confusion will reign!

Jack


On May 18, 2020, at 2:20 PM, Charles Phillips <phillipstriples@...> wrote:

Ok, next dumb question. AppKit does work, thanks. 

In the Objective-C book, it says to use this code:

@property (nonatomic) IBOutlet UILabel *nameLabel;

but it of course does not work. Since UI... is for iOS, I tried:

@property (nonatomic) IBOutlet IBLabel *nameLabel;

but that gives an error also. What is the equivalent for MacOS?

Charles


Charles Phillips
 

Jack, et al -

Amazon had that fourth edition of that Cocoa book and so I bought it. I had been looking for a recommendation for a book like that, I knew it was the interface that I needed to learn about - the actual Objectivep-C code is not that difficult. I got "Objective-C for Absolute Beginners" copyright 2018 hoping that it would cover MacOS programming - because it says that it does. However there are no MacOS examples, it does not mention AppKit anywhere, etc etc. 

When I start a project, I select MacOS and Cocoa, is that what you mean when you say "select macOS templates in the tab bar"? 

Charles


Steve Christensen
 

At the top of the new project panel, you should see tabs for iOS, watchOS, tvOS, MacOS, Cross-platform. The iOS tab is selected by default, I think, so you need to make sure that you’ve selected the macOS tab before then selecting the application type.

On May 18, 2020, at 2:48 PM, Charles Phillips <phillipstriples@att.net> wrote:

Jack, et al -

Amazon had that fourth edition of that Cocoa book and so I bought it. I had been looking for a recommendation for a book like that, I knew it was the interface that I needed to learn about - the actual Objectivep-C code is not that difficult. I got "Objective-C for Absolute Beginners" copyright 2018 hoping that it would cover MacOS programming - because it says that it does. However there are no MacOS examples, it does not mention AppKit anywhere, etc etc.

When I start a project, I select MacOS and Cocoa, is that what you mean when you say "select macOS templates in the tab bar"?

Charles


Jack Brindle
 

First, the answer to your earlier question is NSTextField. IB will show information about the object, including its objet type, if you set it right. For Xcode 11.4 while in the IB object selection window, click on the top right icon in that window. It will split the window to show the objects on the left and textual description of the selected object on the right. And, a hint: hold the Option key when you click on the 
+ button to open the IB panel and it will keep the panel on screen after you selected drag an object to the xib window.

To create a new Mac project, go to the File menu and click New, then drag down to "Project…” and release. A new project window will open with a sheet admonishing you to “Choose a template for your new project:”. There are project templates for each of the Apple platforms, including macOS. Make sure that macOS is selected or you will be creating something you probably don’t want.

One other thing s that will illicit a lot of discussion here. Real Mac developers use xibs and not storyboards. It is really a personal thing, but storyboards came about with iOS. The only time I see them is when we hire a new developer - most come from the iOS world. After we teach them Mac development techniques they become more useful.

Jack



On May 18, 2020, at 2:48 PM, Charles Phillips <phillipstriples@...> wrote:

Jack, et al -

Amazon had that fourth edition of that Cocoa book and so I bought it. I had been looking for a recommendation for a book like that, I knew it was the interface that I needed to learn about - the actual Objectivep-C code is not that difficult. I got "Objective-C for Absolute Beginners" copyright 2018 hoping that it would cover MacOS programming - because it says that it does. However there are no MacOS examples, it does not mention AppKit anywhere, etc etc. 

When I start a project, I select MacOS and Cocoa, is that what you mean when you say "select macOS templates in the tab bar"? 

Charles


Dave
 



On 19 May 2020, at 00:00, Jack Brindle via groups.io <jackbrindle@...> wrote:

Real Mac developers use xibs and not storyboards.

We also don’t eat quiche, but lets not get into that one……...