Document-Based App Woes
Document-Based App Woes
- Subject: Document-Based App Woes
- From: John Bowers <email@hidden>
- Date: Sun, 7 Jan 2007 15:25:45 -0500
Hello gracious souls,
Not sure what I'm doing wrong here. I'm trying to build a document
based cocoa app to edit a simple XML file. To learn how to do this
I'm editing just: <name>Some Name</name> My cocoa app has an
NSTextField input that I want to use to edit the value of the <name>
tag in my XML file. To start I am implementing the -
loadDataRepresentation: ofType: method. I have an IBOutlet to my
NSTextField called nameField. So here is my code so far:
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
NSXMLDocument *xmlDoc;
NSError *err = nil;
xmlDoc = [[NSXMLDocument alloc] initWithData:data options:nil
error:&err];
//some error handling that I am skipping for brevity...
NSXMLNode *aNode = [xmlDoc rootElement];
NSXMLNode *cNode = [aNode nextNode];
NSString *myStr = [cNode stringValue];
[nameField setStringValue:myStr];
[nameField setNeedsDisplay:YES];
}
Now, this is not doing what I want. I'm thinking that the GUI is
created after the MyDocument object, because I can create a button
that takes myStr (after storing it) and is able to set the string
value of nameField.
Can someone point me in the right direction here. I can't quite
figure out how all this pieces together yet. I've completed several
tutorials on the subject but they just seem to work by magic and
don't really explain how the data is getting to the interface.
Thanks for any help.
-John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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