Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSArray Problem

NSArray Problem
Thread Tools
titan44
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status: Offline
Reply With Quote
May 23, 2006, 03:01 AM
 
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.
     
CharlesS
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
May 23, 2006, 03:06 AM
 
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.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
titan44  (op)
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status: Offline
Reply With Quote
May 23, 2006, 03:36 AM
 
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.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 23, 2006, 04:08 AM
 
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'."
     
titan44  (op)
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status: Offline
Reply With Quote
May 23, 2006, 04:30 AM
 
Ultimately no, what i want to do is create a new object in an array every newline.
     
titan44  (op)
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status: Offline
Reply With Quote
May 29, 2006, 12:04 AM
 
Worked it out guys, thats for all the input
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
May 29, 2006, 12:29 AM
 
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'."
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
May 29, 2006, 12:34 AM
 
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.
     
titan44  (op)
Fresh-Faced Recruit
Join Date: Sep 2003
Location: Victoria, Australia
Status: Offline
Reply With Quote
May 30, 2006, 03:12 AM
 
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?
     
Mithras
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Jun 3, 2006, 05:54 PM
 
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.
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jun 4, 2006, 12:10 AM
 
Probably on ridiculous_fish, yeah?
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:58 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,