Re: Performance, Efficiency - Coding practice
Re: Performance, Efficiency - Coding practice
- Subject: Re: Performance, Efficiency - Coding practice
- From: John Ku <email@hidden>
- Date: Thu, 28 May 2009 17:42:56 -0700
Thank you all for the explanation. After reading over and experiment, I kind
of get what you all are saying.I've probably confused myself too much with
the dot syntax to use title = @"fdsfd".
So if i have:
NSMutableString *title = [[NSString alloc] init];
[title setString: @"test"];
That would be correct and safe?
Thank!!
John
On Thu, May 28, 2009 at 5:30 PM, Kyle Sluder <email@hidden> wrote:
> On Thu, May 28, 2009 at 4:57 PM, John Ku <email@hidden> wrote:
> > NSString *title = [[NSString alloc] init];
> > title = @"TEST";
>
> NSString is immutable, and Objective-C doesn't have operator
> overloading. So what you're doing here is creating an empty NSString,
> assigning a pointer to it to your title variable, then immediately
> assigning a different pointer-to-NSString-constant to the same
> variable. = always does assignment in Objective-C; it never means
> "tell this object to change its value to what's on the right side of
> the equals sign."
>
> --Kyle Sluder
>
_______________________________________________
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:
This email sent to email@hidden