PDA

View Full Version : Strange Things: UITextView Save To Plist




JoshAK
Mar 9, 2009, 02:03 PM
When I am saving data form a UITextView to a plist the data is saved except the last letter typed into the UITextView. I'm using:


NSMutableArray *array = [[NSMutableArray alloc} init];
[array addObject:objectname];
[array addObject:objectname2];
[array addObject:objectname3];
//ect
[array writeToFile:[self noteFile1] atomically:YES];
[aaray release];


Everything is saved except the last charter in the text field. Is the a bug or does someone else know the reason?

Thanks,

Josh



jnic
Mar 10, 2009, 05:18 AM
Have you checked the content of the array to ensure that all characters are being passed into it in the first place?

Also, I assume this typo isn't in the actual code:

[[NSMutableArray alloc} init];

JoshAK
Mar 10, 2009, 11:09 AM
Have you checked the content of the array to ensure that all characters are being passed into it in the first place?

Also, I assume this typo isn't in the actual code:

[[NSMutableArray alloc} init];

Yes that is a typo. What is the best way to check the content of the array?

dejo
Mar 10, 2009, 11:21 AM
What is the best way to check the content of the array?
Set a breakpoint and then examine the array in the Debugger.

JoshAK
Mar 10, 2009, 11:27 AM
Set a breakpoint and then examine the array in the Debugger.

Would you use an NSLog()?

dejo
Mar 10, 2009, 11:35 AM
Would you use an NSLog()?
That's do-able. But there's nothing like stopping the code at a particular point and examining the stack trace, variable values, etc. The Debugger is a powerful tool built into Xcode. Take advantage of it.