May I add two questions to this enlightening thread?

1. With ARC, do we still have to worry about string1 leaking in the following 
scenario?

@property (nonatomic, copy) NSString *string1;
…..
self.string1 = @"Hello";
string1 = @"Hello hello";
string1 = @"Hello hello hello";


2. How do the strong, copy and weak keywords in the property declaration affect 
this?

Thanks!

Diederik



Op May 28, 2013, om 10:16 PM heeft Jens Alfke <j...@mooseyard.com> het volgende 
geschreven:

> 
> On May 28, 2013, at 6:39 AM, Alex Zavatone <z...@mac.com> wrote:
> 
>> NSString *myString;
> 
> You’ve declared myString as a _mutable_ pointer to an _immutable_ object. If 
> you had declared it as
> 
>       NSString* const myString = @“Hi";
> 
> then the variable itself would be immutable, and the compiler would give you 
> an error if you tried to reassign it. (You often see this style used when 
> declaring a string constant in a header file, since it’s supposed to stay 
> constant and no one should reassign it.)
> 
> Working with C++ will beat this concept into your head (for better or worse).
> 
> —Jens
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/diederik%40tenhorses.com
> 
> This email sent to diede...@tenhorses.com


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to