Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableString appendString: "appending self" allowed?




On 30/08/2007, at 2:46 PM, Manfred Schwind wrote:

Hi,

is the following call allowed?

[someMutableString appendString:someMutableString];

It effectively appends a given string to itself, so that it gets doubled. (E.g. "Oh" will become "OhOh" etc.)

It works at least on 10.4.10, but it's not documented wether I can use the receiver as parameter in the appendString selector for NSMutableString. Can someone (maybe from Apple) approve that this works also for older system versions?
I can think of strange side effects when appending a string to itself, depending on the internal implementation.


Or should I better use this:

[someMutableString appendString:[[someMutableString copy] autorelease]];

or

[someMutableString appendString:[someMutableString subStringToIndex: [someMutableString length]]];

or something like that?

Have a look at the source code. It's open source.

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden

References: 
 >NSMutableString appendString: "appending self" allowed? (From: Manfred Schwind <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.