Default Cocoa Application ViewController.m issue?

SDGary

Newbie question follows...

I am learning Objective C based OS X Cocoa app development. Most of the books and videos I have are for iOS, so I am converting some simple iOS code examples to OS X.

When I create a new OS X "Cocoa Application" project, with the "use Storyboards" box checked, the default ViewController.m in my newly created project does NOT have an @interface section. Is this expected?

A reply to my recent question Cocoa ViewController.m vs. Cocoa Touch ViewController.m indicates that another user's default ViewController.m DOES have an @interface section.

Currently, I am manually typing the @interface section for IBOutlets. Is that what others are doing? Or do I have some configuration issue?

I am using Xcode 6.3.2 on Yosemite.

Here is my default ViewController.m

//
//  ViewController.m
//  testME
//
//  Created by ME on 6/19/15.
//  Copyright (c) 2015 ME. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
}

- (void)setRepresentedObject:(id)representedObject {
    [super setRepresentedObject:representedObject];

    // Update the view, if already loaded.
}

@end
LOP_Luke

Typically the interface for a class (ViewController in your case) is in the header file (.h).

However some developers use the convention of putting a class extension at the top of implementation files as a way of "faking" private methods (which Objective C doesn't have.)

So you could see this in a .m file:

//The parenthesis here indicate a class extension.
@interface ViewController ()

//Only the ViewController class sees this method.
-(void) method;

@end

@implementation ViewController

-(void) method{
    //Do stuff here 
}

@end

This is not specific to iOS or MacOS but rather Objective C. You can see more about Objective C class extensions here.

The default Xcode project does not add a class extension for the created ViewController class. However if you create a new NSViewController subclass (by going to File->New->File->Cocoa Class, then create a class that is a subclass of NSViewController, you will notice the new NSViewController subclass will have a class extension generated at the top of the implementation file. This however is not required or necessary, just used as a way of defining the closest thing Objective C allows to a private interface.

You can also check out this answer for more details about implementing psuedo-private methods.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

VLCKit: VLCMediaPlayerDelegate in a Cocoa Application

분류에서Dev

NSWindow vs ViewController - OS X - Cocoa

분류에서Dev

Issue with Application.DoEvents()

분류에서Dev

Changing the default program for an application

분류에서Dev

Issue with presenting custom size ViewController modally in ios 8 with keyboard

분류에서Dev

Application has stopped working Issue

분류에서Dev

Cocoa의 스토리 보드가 아닌 앱에서 "ViewController"에 착륙

분류에서Dev

List of all default application programmatically

분류에서Dev

Find the default application for a certain extension

분류에서Dev

VPN default route issue when using the UI

분류에서Dev

Cocoa Application Xcode에서 Json 데이터 표시

분류에서Dev

Core data migration issue - Its crashing the application

분류에서Dev

C# database syncing application identification issue

분류에서Dev

Om/Clojurescript: Issue rendering a reset application state

분류에서Dev

Javascript + Ajax + Django - chat application issue

분류에서Dev

ViewController Cocoa Mac Storyboard Xcode 6 이외의 다른 클래스에서 트리거 된 시트 모달 경고

분류에서Dev

Symmetric encryption issue between a .Net application and a Java application

분류에서Dev

Cocoa OS X AVPlayer-Swift에서 HLS (m3u8) 재생

분류에서Dev

How to set default application for a specific file extension

분류에서Dev

Include our application in default popup to launch the media

분류에서Dev

Windows 7 does not update the default application path

분류에서Dev

Default username and password in Worklight Application Center

분류에서Dev

How to get the default version of an application in unix

분류에서Dev

Setting default application for filetypes via CLI?

분류에서Dev

Cocoa ScreenSaverView

분류에서Dev

Cypress.io on Chrome with "SameSite by default cookies" issue

분류에서Dev

다른 ViewController2.m 파일에서 ViewController1.m에 선언 된 메서드 호출

분류에서Dev

Unity application menus and title bar issue with Wine applications

분류에서Dev

Moskito inspect monitoring tool integration with Java web application issue

Related 관련 기사

  1. 1

    VLCKit: VLCMediaPlayerDelegate in a Cocoa Application

  2. 2

    NSWindow vs ViewController - OS X - Cocoa

  3. 3

    Issue with Application.DoEvents()

  4. 4

    Changing the default program for an application

  5. 5

    Issue with presenting custom size ViewController modally in ios 8 with keyboard

  6. 6

    Application has stopped working Issue

  7. 7

    Cocoa의 스토리 보드가 아닌 앱에서 "ViewController"에 착륙

  8. 8

    List of all default application programmatically

  9. 9

    Find the default application for a certain extension

  10. 10

    VPN default route issue when using the UI

  11. 11

    Cocoa Application Xcode에서 Json 데이터 표시

  12. 12

    Core data migration issue - Its crashing the application

  13. 13

    C# database syncing application identification issue

  14. 14

    Om/Clojurescript: Issue rendering a reset application state

  15. 15

    Javascript + Ajax + Django - chat application issue

  16. 16

    ViewController Cocoa Mac Storyboard Xcode 6 이외의 다른 클래스에서 트리거 된 시트 모달 경고

  17. 17

    Symmetric encryption issue between a .Net application and a Java application

  18. 18

    Cocoa OS X AVPlayer-Swift에서 HLS (m3u8) 재생

  19. 19

    How to set default application for a specific file extension

  20. 20

    Include our application in default popup to launch the media

  21. 21

    Windows 7 does not update the default application path

  22. 22

    Default username and password in Worklight Application Center

  23. 23

    How to get the default version of an application in unix

  24. 24

    Setting default application for filetypes via CLI?

  25. 25

    Cocoa ScreenSaverView

  26. 26

    Cypress.io on Chrome with "SameSite by default cookies" issue

  27. 27

    다른 ViewController2.m 파일에서 ViewController1.m에 선언 된 메서드 호출

  28. 28

    Unity application menus and title bar issue with Wine applications

  29. 29

    Moskito inspect monitoring tool integration with Java web application issue

뜨겁다태그

보관