Possible duplicate:Do I need to release NSString generated using @ "..."?
There are two ways to create an NSString obj object in Objective-C
Method 1:
// string1 will be released automatically NSString* string1 = [NSString string]; // must release this when done
Way 2
NSString* string2 = [[NSString alloc] init]; [string2 release];
If i do
NSString *string = @"This is a string";
My question is, in what direction is the declaration above, and we must finally let it go
String constants should not be freed; they cannot be explicitly released by any self-realized; they are just constants and never freed.
So, just-select them if you saved them before.
in the first and last, you do not own (select and initialize) the line, so do not release them. while in the second you selected it manually, so you need to free it. if you use objects in your code, you must use the second, the other use the first or last
if you use ARC, you shouldn't have a release huff at all just put string = nil; however no you don't need to release this
string = nil;
if you alloc it, then you should release it.
alloc
release
created using a static method of type
static
[NSString stringWithXXXX];
are auto released
auto released
@ H2CO3 is valid with respect to constants.
Source: https://habr.com/ru/post/1411112/More articles:to integrate a simple java application with ADFS2 - javaCreate a deep copy of a C ++ array - c ++In SQL Server, is all the values ββof the Text column set to NULL to reduce the size of the database? - sqlDjango Celery's tasks do not end and always remain on hold - pythonUnderstanding Entity Code Generated by Spring Roo for GWT - spring-rooMissed Actions and Event Procedures in Firemonkey - delphiRepresentation of rotation components in UML class diagrams - javaRedirect the user when he is not authorized to the page in MVC3 - c #Cannot use charray ArrayList as method argument - javaMultiple assignment operations in a single lambda expression - c #All Articles