NSBrowser and lots of data
NSBrowser and lots of data
- Subject: NSBrowser and lots of data
- From: Tim Davis <email@hidden>
- Date: Sun, 29 Jul 2007 20:03:40 -0400
Hello all (again),
So I'm working on my first ObjC/Cocoa application after giving
up .NET and I was wanting to see what advice, if any, you guys could
give me. I've got my program working currently but it
seems...hrmm..slow and memory intensive.
Purpose of the software:
This is a type reflector tool for OS X, mainly to be used by .NET/
Mono programmers. It shows reflected types/classes/methods
etc...from .NET assemblies. I use the doc output from monodocer to
populate a directory of files, within these files is the xml that
describes the class and all of it's available public and protected
methods. I know...you guys aren't interested in .NET but I just
wanted to explain clearly what the goal is.
What I'm doing now:
The outputted directory structure generated by the monodocs tool
isn't that easy to navigate. In .NET a sample namespace is System,
another namespace is System.Xml, and it can also have more (ie.
System.Xml.Schema).... The optimal favored directory structure would
be /System/Xml/Schema for example. But it just creates a folder
called "System.Xml.Schema".
Currently what I do, once the docs are generated, is I parse through
them and grab the relevant info. (ie, Namespace, Scope, Methods/
Properties) and write all this data into one large XML file.
Here's an example for the namespace "ShadowMud.Systems.CommandSystem"
<Root>
<Namespaces>
<ShadowMud>
<Systems>
<CommandSystem>
<CommandController>
<Member Type="Constructor"
Scope="public">.ctor</Member>
<Member Type="Method" Scope="public">Add</
Member>
<Member Type="Method" Scope="public">Count</
Member>
<Member Type="Property"
Scope="public">CurrentCommand</Member>
<Member Type="Event" Scope="public">Error</
Member>
<Member Type="Property"
Scope="public">Processing</Member>
<Member Type="Method" Scope="public">Start</
Member>
<Member Type="Method" Scope="public">Stop</
Member>
</CommandController>
<CommandObject>
<Member Type="Constructor"
Scope="public">.ctor</Member>
<Member Type="Constructor"
Scope="public">.ctor</Member>
<Member Type="Constructor"
Scope="public">.ctor</Member>
<Member Type="Property"
Scope="public">Arguments</Member>
<Member Type="Property"
Scope="public">ClientID</Member>
<Member Type="Property"
Scope="public">Command</Member>
<Member Type="Property"
Scope="public">Prompt</Member>
</CommandObject>
</CommandSystem>
</Systems>
</ShadowMud>
</Namespaces>
</Root>
There's alot more than that, I don't want to liter your email boxes
with needless junk. After I parse all that into the file, the file
is loaded into an NSXmlDocument.
I retain that XmlDocument for use as the user navigates the
NSBrowser. The NSBrowser is setup so each column is the Namespace
contents, or class contents of the previous column's selected item.
I do this by simply grabbing the pathToColumn, and coincidently that
is a valid XPath I can use to gather the nodes that are needed for
the column being currently displayed.
In the following xml example, Click on ShadowMud, new column contains
1 item (CommandSystem), click on CommandSystem new column contains 2
items (CommandController, CommandObject), click on CommandController
and new column contains the <Member>'s for that type. Pretty simple
right?
In my NSBrowser delegate I just use the XPath to return all matching
nodes from the xml tree and return objectAtIndex depending on what
row it's asking for...I'm thinking that this is the slow down, if a
column has 100 rows, it's querying this a hundred times...
Here's an example screenshot of the current work finished...(PS In
the screenshot I'm in System.Xml, XmlDocument is a type (class) so
the next column shows it's members.
http://www.binarymethod.com/files/images/node45.png
What am I asking???:
Clicking on things and the new column opening up performs very
slowly. Also my simple app is hogging 53 Mbs of memory. I was
wondering if any of you had any ideas, or advice on how to keep it
speedy???
Here's some ideas I've had..
1) Rearrange directory structure so it follows namespace paths (ie. /
System/Xml/Schema) and use a NSFileManager to tell the NSBrowser what
goes in what row in what column.
2) I've read a little on binding xml trees, but I have no clue what
binding is or how to use it and the docs I find aren't very
informative for a newb like myself.
....Well, if you read all of that then I thank you very much and
please shout out any ideas you might have to make my memory footprint
lower and speed it up...
Thanks
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden