• 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: Two basic questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Two basic questions
      • From: Markus Hitter <email@hidden>
    • Re: Two basic questions
      • From: Izidor Jerebic <email@hidden>
  • Prev by Date: Re: NSWorkspaceRecycleOperation and auto-renaming items moved to Trash
  • Next by Date: Re: Two basic questions
  • Previous by thread: Two basic questions
  • Next by thread: Re: Two basic questions
  • Index(es):
    • Date
    • Thread