Weird problem with writeToUrl:ofType:error
Weird problem with writeToUrl:ofType:error
- Subject: Weird problem with writeToUrl:ofType:error
- From: Jean-Nicolas Jolivet <email@hidden>
- Date: Thu, 15 Nov 2007 13:58:58 -0500
I'm implementing writeToUrl:ofType:error in my document to save some
data as a simple text file. This document also serves as a datasource
for a TableView. Basically just an NSMutableArray with some simple
objects in it (that are displayed in the TableView)....I can add/delete
object to the array and these objects are then displayed in the
NSTableView... that part is working well...
When saving the document (i.e. in writeToUrl) what I am doing is rather
simple..just looping through the NSMutableArray, and formatting each
object to a string (that part isn't a problem..I added a "toString"
method to my objects...). I append that string to a MutableString that I
will then save to a text file once the loop is done...
So far, everything seems to be working... the only problem is that... in
the writeToUrl method, my NSMutableArray's count is always 1.... it only
contains the first object (the one which I add on initialization so the
tableview isn't empty)... any new objects that were added to the
NSMutableArray aren't there...
What's even weirder is that I added a bogus button that will display my
NSMutableArray's count in the log whenever I click on it.... and even
there, I get the correct count... (for example: Current Array Count:
10).... Then I save the document...and in writeToUrl, I re-print the
count in the log and I get: Current Array Count: 1.... and only the
initial object is being saved in the file....
It seems as if the writeToUrl method was using a different Array...I
don't see how it would be possible? My NSMutableArray is an instance
variable of my Document class... the Array's count seems to be correct
at any given moment....except when saving (in writeToUrl...)...
Any help would be appreciated!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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