On 8/29/11 10:39 PM, Graham Cox wrote:

NSDocument and NSView are totally unrelated classes.


[...]
So your view will be doing stuff like:

[myDocument giveMeDataForLinesInRange:linesRange];// in -drawRect:

and your document will be doing stuff like:

[myView setFrame:theSizeICalculatedFromTheData];

Sorry to keep this going. I am hopelessly lost in the Class and Instance abstractions here. I do not think I am alone as I feel I have spent most of the day with google. Reading the fustrations and confusion of others, who can not quite seem to "see the light."

I have an array of dictionaries. This is defined in the MyDocument class. Inside MyDocument.m I can read, load NSLog and do anything I want with this structure.

The basic for this is really simple.

<code
@interface MyDocument : NSDocument
{

    NSMutableArray *CISEvents;
}
/code>

Reading a bunch of stuff online, I found how to use X code scripts and create getters and setters. This gave me a whole bunch of acessors, most of what make sense. like:
<code
- (NSArray *)CISEvents {
    if (!CISEvents) {
        CISEvents = [[NSMutableArray alloc] init];
    }
    return [[CISEvents retain] autorelease];
}
/code>

Problem is when I want to see this array in my view class file CISView.m Which is based on the RulerView sample code. I define a simple logline.

NSLog(@"have %lu events.",[[MyDocument CISEvents] count]);

I get the error:
 'MyDocument' may not respond to '+CISEvents'

Tried changing the + to - and got 'instance variable '' accessed in class method.' all over the MyDocument.m file.


After a day of reading I see things saying I may need to create a "singleton." in the CISView.m file. Other more confusing helpful suggestions have stuff set in interface builder and setting outlets and such. But I am dealing with the database linedrawing into cliprects and scrollbars, not calculators iPhone apps and such.

The closest I found was to try something like:

standardCISDocument = [[MyDocument alloc] init];
NSLog(@"have %lu events.",[[standardCISIDocument CISEvents] count]);

The code I want to use for my view is based on the NSRuler sample code. This has a +initialize to set the ruler graticule. I need to set the ruler graticule dependent on information inside one of the array dictionaries.

The compiler will not let me put the above code into +initialize as it complains about instance abstractions that are confusing. the same 'instance variable '' accessed in class method. warning. If one has an accessor, then why can it not access?

I read all about car and factory methods classes and such. Not to mention examples relating to apples oranges and bananas.

But no where do I see a clear concise explanation for 35+ year assembly language postscript C language programmers who still believe with religious dogma that ints are pointers and pointers are ints! I never liked private variables, but am open to evangelical conversion if the arguments are clear.

The apple documentation is so curcumlocutious as to feel like a works program for out of work document writers. Where are the code examples next to the class instance declarations. Again what files do things go into? It is all about where in the files to put things.

I tried putting the above "singleton" code in -awakefromNib, but I get 0 count. The View awake is called before the MyDocument awake but after the -readfromURL stuff.

I tried adding a plain -init. This never seems to get called. It seems like there are too many ways to do things and ever so much overhead, which is good when paid by the hour. Not so good when writing shareware and customware for oneself.

I have all of this working in Carbon/Quickdraw. Plus another postscript file that does exactly what I want. Not sure what is more of a waste of time, maintaining that or learning cocoa. Problem is my 5 powerpc computers are not going to be of much use soon, so will need this to run on what ever I can get.

I keep going over the cocoa tutorials, but they are completely set on doing what has been done before. I got buttons down, I got departments and employees down to make great lists of data.

I just can not figure out how to get my data array across multiple *.m files to initialize frame abstraction and call drawRect. So that I can scroll 25,000 to 10,000 lines. withouth having to create image data sources, since my images are lines draw on as as needed basis.


-julie








_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to