|
|
#1 |
|
Problems understanding ARC and zombies
I started learning Cocoa when there still was the manual counting, but after few time I got the new OS update and ARC was available.
I know how to user retain-release if I don't use ARC, but the problem comes with ARC enabled.I always used strong references and everything was fine, never had leaks nor dangling pointers. But I want to understand better how it works. Now I am running a project for debugging, with zombies enabled.I tried do do this: Code:
__unsafe_unretained NSString* str;
@autoreleasepool
{
str= @"Hello";
}
NSLog(@"%@",str);
Also a tip, should I start making some projects with manual counting to understand how ARC works? |
|
|
|
0
|
|
|
#2 | |
|
Quote:
|
||
|
|
0
|
|
|
#3 |
|
To get what you're looking for, use
Code:
str = [NSString stringWithString:@"Hello"] I think NSString has a stringWithString method, but I can't verify it right now. |
|
|
|
0
|
|
|
#4 |
|
+stringWithString: will short-circuit to just using the argument directly in this case. -mutableCopy should get what he wants.
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 11:39 AM.








Linear Mode
