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

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
I have been developing a little Cocoa app recently to help me manage my money whilst at Uni. It's been coming along very nicely, and seems to works pretty much just as I'd like. It currently looks like this:
proto2.jpg


I have added the ability to save the file through - (NSData *)dataRepresentationOfType: (NSString *)aType in MyDocument, but I'm not sure how to implement loading. I have uploaded the XCode project here if anyone would like to take a look at it and help me out. The example in the Hillegass is pretty different to my app and I can't work out how to add loading in my application. I'm sure one of you guys could figure it out though.
 

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
OK I looked at a file I saved in Property List Editor and it's saving all the values as 0, so save isn't actually working at all. If someone with some Cocoa experience could please look at this I'd be very grateful.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
You have to tell your object controller what it's controlling. The values aren't getting saved because the bindings system isn't even setting the values of your variables in the first place. In this case, you want it to link to the detailsController in your document, so in IB, bind the "Controller Content" of objectController to File's Owner (your document), with the path as "detailsController".

For loading it, just do something like this:
Code:
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType {
	detailsController = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    return YES;
}
It can get a little more complicated if you want to do a bunch of custom stuff, but I think that would work in this case.

bindings.png
 

stadidas

macrumors regular
Original poster
Feb 27, 2006
243
0
Kent, United Kingdom
Thank you so much! :) I'm very new to Cocoa and rushed through the Hillegass book a bit, that was a really stupid mistake to make.
I'm putting a special thank you to you in the 'About' window... not that you probably care as I'm the only person who's likely to use the program.
Thanks again though!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.