Text storage
Text storage
- Subject: Text storage
- From: April Gendill <email@hidden>
- Date: Mon, 11 Aug 2003 11:01:58 -0700
Ok....
let me get something out of the way.
if the documentation made sense to me I would not write the list.
if the example code made sense to me I would not write the list.
if the books answered my question I would not write the list.
I do not have a degree in computer science
I do not have time (working two jobs for the pleasure of paying bills)
to go to school and if I did what school teaches cocoa? none within 600
miles of where I live.
So...
Just for the purpose of testing I am using the userdefaults because
they are easy. later the data storage will be in a plist in the main
bundle so I don't need advice on how using the preferences is a no no.
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[super windowControllerDidLoadNib:aController];
[defaults setObject:@"Testing" forKey:@"0"];
// i did this simply to make sure a) that the info was written and
b)that it could be read from the preference file into the textview.
theNotes=[defaults objectForKey:@"0"];
//currently, the line for writing to the preferences is commented out
and it reads correctly. so this much is working.
[page insertText:theNotes];
NSLog(@"Page 1: %@",[page string]); //string is a method see below
this also correctly prints the word Testing
NSLog(@"TheNotes: %@",theNotes);// this prints the string "Testing"
to the console just as it should
}
- (NSAttributedString *) string { return theNotes; }
Ok, theNotes is a NSAttributedString declared in the header file. I can
give it value in windowcontrollerdidloadnib method but once that method
is finished the data is gone and any other attempts to nslog or use
theNotes give me null.
the variable "page" is declared in the header as an NSTextView. it
prints the right info in the above method, all other attempts to print
the information to the console from other methods is null.
when the document appears on the screen the word Testing appears in the
window.
if I edit the contents of the window and then quit the app (remember it
is suppose to write the contents of the text view into the preference
file.) no data is written and NSLog of theNotes or [page string] prints
null
at one point i tried these two methods:
- (void) setString: (NSAttributedString *) value {
theNotes=value;
NSLog(@"the Notes from Set string %@",theNotes);//this prints null
}
- (NSAttributedString *) string { return theNotes; }
to maintain the data for theNotes.
there was no success.
trying to NSLog theNotes was still null . NSLog(@"%@",[notes string]);
trying to declare [notes setString:theNotes]; or anything else does not
work. and if memory serves
[notes setString:@"Test"]; still fails to produce anything.
returned null. (notes having been declared at the top of the
applicationwillterminate method.
so... I can get data from the preferences or static assignment into the
text view.
HOW then do I get the data that is in the text view back into some kind
of variable that will save into the preferences, and ultimately, when
the structure of the application is finished, into a file in the main
bundle?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.