• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: make a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make a list


  • Subject: Re: make a list
  • From: Alexander Spohr <email@hidden>
  • Date: Fri, 5 Dec 2003 19:19:02 +0100

the second run has to be a loop through the first array's contents:

+ (NSArray*) convertString:(NSString*) theString;
{
NSArray *anArray = [theString componentsSeparatedByString:@"\r"];
NSMutableArray *aMasterArray = [NSMutableArray array];
for(i=0; i<[anArray count]; i++)
{
NSString *aString = [anArray objectAtIndex:i];
[aMasterArray addObject:[aString componentsSeparatedByString:@"\t"]];
}
return aMasterArray;
}

atze

Am 05.12.2003 um 19:13 schrieb Sascha Kuehn:

you question went to the cocoa-list.
so no C++ answer here, only Objective-C.

try NSStrings - (NSArray *)componentsSeparatedByString:(NSString *)separator
that breaks your string into parts and delivers an array. then run that array, to separate the contained strings again.

the first run works very well with this code:
@implementation string2list
+ (NSArray*) konvertString:(NSString*) theString;
{
return [theString componentsSeparatedByString:@"\r"];
}
@end

but the second run gets an error.
what is wrong. how can i get a list of lists?

Sascha


atze


Am 05.12.2003 um 17:56 schrieb Sascha Kuehn:

hi,

i need to make a list of lists from a tab and return delimited string
like : "data1 [tab] data2 [tab] data3 [return] data4 [tab] data5 [tab]
data6"
[tab] and [return] are the delimiters!!

this string should become a list like: {{"data1", "data2",
"data3"},{"data4", "data5", "data6"}}

i have an applescrip:

set x to (mysql's ExecuteMySQLCommand(sqlCommand))
set addressData to {}
set AppleScript's text item delimiters to return
repeat with i from 1 to count text items of x
if i - 1 then
set y to text item i of x
set AppleScript's text item delimiters to tab
set _name to text item 1 of y & " " & text item 2 of y
set end of addressData to {_name, text item 3 of y, text item 4 of
y, text item 5 of y}
set AppleScript's text item delimiters to return
end if
end repeat

but this is to slow.
i.e. the script needs for 188 text items of x about a minute on a eMac
1Ghz!

i guess a c++ routine will be much faster bu i don't have any
experiences with c++ so anybody can help me?

Sascha
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: make a list
      • From: Sascha Kuehn <email@hidden>
References: 
 >make a list (From: Sascha Kuehn <email@hidden>)
 >Re: make a list (From: Alexander Spohr <email@hidden>)
 >Re: make a list (From: Sascha Kuehn <email@hidden>)

  • Prev by Date: Re: make a list
  • Next by Date: Re: make a list
  • Previous by thread: Re: make a list
  • Next by thread: Re: make a list
  • Index(es):
    • Date
    • Thread