Amy Heavey wrote:

... I've tried just using strings, but the applicationSupportFolder returns a string, which then is immutable so I can't add to it?

There's a significant misconception lurking here.

None of the NSString methods for appending or deleting actually modify the NSString they are applied to. A new NSString instance is created that contains a copy of the original's contents plus whatever contents is to be appended, or minus the contents to be deleted, or with some parts replaced, or whatever the operation is. The original NSString is never modified in any way.

The methods whose name starts with "string", as in "stringByAppendingString", return an NSString object that the caller does not own. See the Memory Management Guide on ownership for the consequences (i.e. the uses of retain and release).

Also see the NSString reference doc, and read the descriptions under stringByAppendingString and others. Example:

"Returns a new string made by appending a given string to the receiver"

The critical words are "a new string" and "made by".

The same is true of NSMutableString, when those same methods are applied. A new NSString is made that contains the altered copy of the contents, and that instance is returned.

The only NSMutableString methods that modify the target object are the ones listed under "Modifying a String" in the NSMutableString reference doc. All the methods inherited from NSString are non- modifying.

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ Foundation/Classes/NSMutableString_Class/Reference/Reference.html

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to