Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

slooksterPSV

macrumors 68040
Original poster
Apr 17, 2004
3,543
305
Nowheresville
Ok, I'm extending my MDM application (MoneyData Manager). Here's what I need help with doing:

The user will have two table views, one to choose their account and the second to display transactions with that account. Ok I've got it to where you can add data to one or the other, but selecting won't show what should be in the other. Anyways I know how to do that. Here's my problem:

When I archive the data, how will I get the data for the other transactions? I figure I'll have to make an array of an array of the data.
E.g. Accounts->Transactions->the actual transactions data, so you'd have this:
Account 1:
Transactions:
a, b, c
a, b, c
Account 2:
Transactions:
a, b, c
a, b, c

Now I think I know how I'll unpack the data, unpack the data into an array then unpack each array item into an array for those transactions.

Do you follow with what I'm asking?
I want to know how I'd get the data from the other accounts. I guess I'm not sure what I'd do, should I do a for loop or... see I'm lost on what to do.
 

slooksterPSV

macrumors 68040
Original poster
Apr 17, 2004
3,543
305
Nowheresville
Ok I started to write it and it makes sense now, but now I have another issue, when the user double dlicks on the account name, it deallocates MoneyData which is a class I need to use, so I don't know how I can keep it from deallocating.

EDIT: I'm not sure how its deallocating it. Here's what I'm doing:
When the user creates an account and clicks on it, it SHOULD load the data for that account via an array stored in the account. e.g.
//... rest up here
{
NSString *accountName;
NSMutableArray *transactions;
}
//... rest down here

ok now here's what I do when the user clicks on the table:
Code:
- (void)showTransactionsForAccount:(id)sender
{
	NSLog(@"You chose %d", [accountView selectedRow]);
	if([accountView selectedRow] >= 0)
	{
		transactions = [[accounts objectAtIndex:
			[accountView selectedRow]]transactions];
		if(transactions == nil)
		{
	
		}else{
			NSLog(@"Hello");
			[self setTransactions:transactions];
			[tableView setNeedsDisplay:YES];
		}
	}
}
I set the MyDocument.h's transactions value to the accounts transaction data. Here's the insertobject method it calls:
Code:
- (void)insertObject:(MoneyData *)d inTransactionsAtIndex:(int)index
{
	int row = [tableView numberOfRows]-1;

	// Add the inverse of this operationg to the undo stack
	NSUndoManager *undo = [self undoManager];
	[[undo prepareWithInvocationTarget:self] removeObjectFromTransactionsAtIndex:index];
	if(![undo isUndoing]) {
		[undo setActionName:@"Insert Transaction"];
	}
	//Add the Person to the array
	if(row > -1)
	{
		MoneyData *prev = [transactions objectAtIndex:row];
		[d setCurrentAvail:[prev totalAmount]];
		[d setTypeOfTransaction:[prev typeOfTransaction]];
	}
	[self startObservingTransaction:d];
	[transactions insertObject:d atIndex:index];
}
But it won't do anything if the user has created and clicked on an account cause it says key value coding blah blah blah while MoneyData is being deallocated.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
Have you had a look at Cocoa bindings? They aren't necessarily what you need yfor every job but they're really good for situations like this where you have a selection for one GUI object that then shows the details of that selection somewhere else.
 

slooksterPSV

macrumors 68040
Original poster
Apr 17, 2004
3,543
305
Nowheresville
Code:
- (void)showTransactionsForAccount:(id)sender
{
	NSLog(@"You chose %d", [accountView selectedRow]);
	if([accountView selectedRow] >= 0)
	{
		NSMutableArray *transAcct = [[NSMutableArray alloc] initWithArray:[[accounts objectAtIndex:
			[accountView selectedRow]]transactions]];
		NSLog(@"%@", transAcct);
		if(transAcct != nil) {
		[transactions release];
		transactions = transAcct;
		[self setTransactions:transactions];
		[tableView setNeedsDisplay:YES];
		[transAcct release];
		}
	}
}

I have an array in my Account.h which will hold the transactions, so that I can click on an account and it'll go through the array of accounts to get the accounts transactions.
You can see some issues with the above code? I'm not sure how to do all this.

Account has its own NSArrayController with a binding to its modeler accountName.

Do you just want me to zip the entire project and see if you guys can figure it out, I'm so lost.

EDIT: When I choose a different name or click on the same account it goes into the GDB and starts giving me error locations, but I'm not sure what the error is.
 

almightyshoe

macrumors regular
Jun 4, 2006
118
0
B-Town, India
Why can't you load the files on Panther? (I ask because I work tech support at the Uni, and we have one powerbook here running Panther, while the rest of the campus runs Tiger-soon-to-run-Leopard)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.