• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: importing MyDocument.h compiler errors and warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: importing MyDocument.h compiler errors and warnings


  • Subject: Re: importing MyDocument.h compiler errors and warnings
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 18 Oct 2006 08:31:54 +0100


On 17 Oct 2006, at 22:52, Derrek Leute wrote:


In my objects I need to know the document they belong to. To accomplish this, I created a reference to the currentDocument upon the object initialization. Simplified Code:


@interface TreeWrapper : NSObject
{
	NSDocument *document;
}

- (id) init
{
self = [super init];
if (self != nil) {
document = [[NSDocumentController sharedDocumentController] currentDocument];
}
return self;
}

Can I point out that this isn't a particularly good idea. The current document may not in some cases be the document to which the objects belong. Instead, you want methods like:


- document
- setDocument:

in your TreeWrapper class. Whatever object is responsible for creating a TreeWrapper object should do something like:

TreeWrapper *newTreeWrapper = [[TreeWrapper alloc] init];
[newTreeWrapper setDocument: [self document]];

Hope that helps,

Mike.


This works fine except it generates compiler warnings as I try and call methods that are custom to my subclass of NSDocument. The program compiles and runs as expected though.


If I switch it to MyDocument *document I need to also import "MyDocument.h". This causes some sort of error where it can't find the TreeWrapper which is the super class to my data objects.

"error: cannot find interface declaration for 'TreeWrapper', superclass of '(one of my subclasses)'

It generates this for many of my data objects. The problem seems to be that including MyDocument.h reincludes my root data object which is a sub class of TreeWrapper.

Anyone have any ideas?

--Derrek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >importing MyDocument.h compiler errors and warnings (From: Derrek Leute <email@hidden>)

  • Prev by Date: Re: get iTunes songs
  • Next by Date: Re: NSButtons have drawing "artefacts" around them when clicked on a window/custom view bezel
  • Previous by thread: Re: importing MyDocument.h compiler errors and warnings
  • Next by thread: Cocoa Window layered over OpenGL?
  • Index(es):
    • Date
    • Thread