|
|
NSArray Problem
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
Hi all,
I've got a .csv that i've split up with NScanner and ready to write to another file, but i want to be able to check the file first to see if the string i want to write to the file already exists in it. So I've got a NSArray to read in the file with componentsSeparatedByString:@"\n" what i want it to do is read in the file until \n then create a new object at the next index, but it seems to create one large object with line breaks, any ideas?
Thanks.
|
|
|
|
|
|
|
|
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
Is the original .csv file possibly using CR instead of LF for line breaks? That would result in your file not having any \n characters in it, and thus not getting separated, but still having line breaks due to the \r characters.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
no it's using \n , I'm looping thru the same file with an NSEnumerater at an earlier point in the program and using componentsSeparatedByString:@"\n" to split it up, this part is working fine, so i don't think it's that.
Thanks for the info though.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Wait, so componentsSeparatedByString: is splitting it up properly at one point in the program, but not later?
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
Ultimately no, what i want to do is create a new object in an array every newline.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
Worked it out guys, thats for all the input
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
If you could briefly explain what was wrong and how you fix it, that would be useful for anyone searching about the same problem in the future. Just a suggestion.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Yeah, it's always nice to see the solution here, but since I could never understand what the problem was in this thread anyway, I guess it's not such a big deal.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status:
Offline
|
|
Yeah, sorry about the vagueness guys - one too many late nights staring at code, what i ended up doing was scanning the line up to the line break, dumping that into a string, then adding that to a mutable array. ( i wanted to avoid using NSScanner 'cause i found it's a bit on the slow side, and i've got thousands of records to process ).
Which brings me to another question ( if i may ) what is the storage limit in NSString, NSArray, and NSMutableArray?
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status:
Offline
|
|
Not hard and fast, but NSArray should work into the millions. I recall reading somewhere that NSArray switches internal representations somewhere around 300,000 objects.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|