On 8 Jan 2013, at 15:35, Pirmin Braun wrote: > Am Tue, 8 Jan 2013 14:51:07 +0000 > schrieb David Chisnall <thera...@sucs.org> : > >> On 8 Jan 2013, at 14:41, Pirmin Braun wrote: >> >>> NSString *s1 = [[a oai:i]copy]; >> >> For an immutable string, -copy just calls retain. If you want to actually >> copy the string, do something like: >> >> NSString *s1 = [NSString stringWithUTF8String: [old UTF8String]]; >> >> (for better performance, you might want to use getCharacters:range: and a >> temporary buffer, so that the old string doesn't have to create a new >> autoreleased buffer). >> >> David >> >> -- Sent from my STANTEC-ZEBRA >> > > ok, changed it like this: > NSArray *a = [self componentsSeparatedByString:s]; > NSMutableArray *ma = [NSMutableArray arrayWithCapacity:[a count]]; > int i,j; > > // deep copy of a > for(i=0,j=[a count];i<j;i++){ > [ma addObject:[NSString stringWithUTF8String:[[a oai:i]UTF8String]]]; > } > return [NSArray arrayWithArray:ma]; // immutable > > but also no difference; I give up. For the moment.
You need to wrap things in an autorelease pool so that you can release the array by releasing the pool ... 1. create pool 2. call -componentsSeparatedByString: 3. make deep copy of resulting array 4. release pool 5. autorelease and return the copied array _______________________________________________ Gnustep-dev mailing list Gnustep-dev@gnu.org https://lists.gnu.org/mailman/listinfo/gnustep-dev