• 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
Unidentified Nib'ed Instance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unidentified Nib'ed Instance


  • Subject: Unidentified Nib'ed Instance
  • From: Seth Willits <email@hidden>
  • Date: Fri, 26 Mar 2004 22:26:29 -0800

In my NSDocument subclass (MyDocument) I have a reference to a custom class that wraps all of the data of the document (MyData). In the init method of MyDocument I create and initialize MyData by:

mMyData = [[MyData alloc] init];
[mMyData retain];

(BTW if someone can refresh me how to make init a class method that allocs and does all of the typical stuff I would want it to, I'd appreciate it, but if it's more than five lines I wouldn't bother - I'll look around and find it.)


Since I want to create some custom NSTableView subclasses which would be their own delegates and data sources, I wanted to pull the mMyData reference out of MyDocument and instantiate it in the document's nib file. I would then make outlets in each of the classes that need access to it (MyDocument and the custom tables).

When trying this, suddenly everyone thinks the mMyData reference points to an NSArray! If, for example, MyData contains a method "doCoolStuff" and I call it from within MyDocument, what happens is I get an error like this:
-[NSCFArray doCoolStuff] selector not recognized

And then the document window fails to open. I'm not sure why it's doing this. The steps I took were:



1) Change the interface for MyDocument from:
MyData* mMyData;
to
IBOutlet MyData* mMyData;

2) Removed
mMyData = [[MyData alloc] init];
[mMyData retain];

from the [MyDocument init] method and placed
[mMyData init]
in windowControllerDidLoadNib. (Remember init isn't a class method)

3) Dragged the header files into the nib to reparse them
4) Instantiated MyData
5) Connected the MyData instance to the "mMyData" outlet in File's Owner (which is the MyDocument class)

Running the project yields the error.



Do any of you have any clue as to why this is happening?




Seth Willits
------------------------------------------------------------------------ ---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames

"When one door of happiness closes, another opens; but often we look so
long at the closed door that we do not see the one which has opened for us."
-- Hellen Keller
------------------------------------------------------------------------ ---
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Unidentified Nib'ed Instance
      • From: Glenn Andreas <email@hidden>
  • Prev by Date: Re: Split Views
  • Next by Date: Re: NSAppleScript leaking memory?
  • Previous by thread: Re: Split Views
  • Next by thread: Re: Unidentified Nib'ed Instance
  • Index(es):
    • Date
    • Thread