Re: Two basic questions
Re: Two basic questions
- Subject: Re: Two basic questions
- From: David Newberry <email@hidden>
- Date: Thu, 28 Feb 2002 07:30:23 -0800
2) Is there some reason a NSMutableString should not be returned from a
string? Any time I try it seems to cause problems. Am I maybe doing
something else wrong, or is there something inherently wrong with doing
this? Returning an NSString seems to be fine.
Can you clarify this? What do you mean by "returned from a string"? It
might help to see an example from your code, and what it does as opposed
to what you want it to do.
Acks, oops. Sorry, I meant; "returned from a function". Sorry about that
all.
Eg, I'll do something like this:
- (NSString *)myFunc
{
NSMutaleString *string = [NSMutableString stringWithCapacity:0];
[string appendString:@"test"];
return string;
}
And then later when I try to use the string that was returned from this
function, I'll get an error relating to malloc. A double-freeing, as I
recall. The problem doesn't occur if I use an NSString and then use
NSString stringByAppendingString:.
Disclaimer: The above code is not copy and pasted, so errors due to typing
in Mail.app may have arrisen. But that's the idea.
--Andy
Thanks,
-Davd
_______________________________________________
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.