• 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: Memory management with nibs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory management with nibs


  • Subject: Re: Memory management with nibs
  • From: Julien Palmas <email@hidden>
  • Date: Fri, 22 Apr 2005 09:26:44 +0900

Well, let me clarify a bit what I said before.
There is only ONE type of document I open. That is to say, all the documents have the same file extension.


BUT, those documents can contain a wide variety of different information. And one document is not bound to contain this kind or this kind of information ...

Hence, I created a sub class of NSDocument containing the common nib and information for each document. Those nibs are correctly released when closing a document.
But I also have other nibs, one for each different piece of information present in the document. Let's say there are 50 different nibs, being able to load only 2 of them if necessary is much more efficient that always loading the 50 !!!


My question is about the file owner for those nibs. What class (sub class) should I use. I don't want to make the NSDocument the file owner. And what should I do to make sure those nibs are correctly released once the document closed?

On Apr 21, 2005, at 8:49 PM, Dirk van Oosterbosch wrote:

Hi Julien,

AFAIK the standard way to deal with multiple types of documents and multiple different UI's is to make multiple different subclasses of NSDocument.
These then are set in the corresponding nib to be the File's Owner, you override - (NSString *)windowNibName to return the appropriate nibname and you change the NSDocumentClass keys in your Info.plist so the NSDocumentController knows which NSDocument subclass to use to open your files with.


or review the documentation again
http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/ index.html?http://developer.apple.com/documentation/Cocoa/Conceptual/ Documents/Tasks/SubclassNSDocument.html



I believe then everything is managed for you and you don't have to concern about releasing of the nib's


HTH

Best,
dirk


On 21-apr-05, at 11:05, Julien Palmas wrote:

I have a document based app with only one window per document.

This application can open a large variety of different documents, so I decided to create several nib files, each containing the corresponding view for the document.

When opening the document, I check its kind and load the according nib. This helps reduce the application footprint and the load time, as I don't open all the nibs ...

Still, This is my first document based app and I have issues about the files owner. For each different nib, I created a subclass of NSObject and set it as the file owner when I load the nib with [NSBundle loadNibNamed:] This owner has several IBOultets, but not for every single element in the nib.

The thing is that when I release the owner, I don't think the nib is released as well, as my nib owner is not a sub-class of NSWindowController. But as I only have one window (that already has its NSWindowController), I didn't wanted to use a sub-class of NSWindowController for the nib owner.

How could I do to make sure my nib is released ?

Some "good-coding" advices would be greatly appreciated.

Julien

_______________________________________________
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


-----------------------------
Dirk van Oosterbosch
de Wittenstraat 225
1052 AT Amsterdam
the Netherlands

T ++ 31 20 7765565
M ++ 31 6 48401910
W http://labs.ixopusada.com
-----------------------------


_______________________________________________ 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
  • Follow-Ups:
    • Re: Memory management with nibs
      • From: Ondra Cada <email@hidden>
References: 
 >Memory management with nibs (From: Julien Palmas <email@hidden>)
 >Re: Memory management with nibs (From: Dirk van Oosterbosch <email@hidden>)

  • Prev by Date: Re: Category or Protocol? (sidetrack)
  • Next by Date: Re: Category or Protocol? (sidetrack)
  • Previous by thread: Re: Memory management with nibs
  • Next by thread: Re: Memory management with nibs
  • Index(es):
    • Date
    • Thread