objective c - NSString and NSData Memory Management -


I have the following code to create NSString in which the body of the text file is included and then convert it to NSDT Do it and output it to a file.

  NSString * particleString = [[NSString alloc] initWithFormat: @ "% @", @ "This is the main part of my file"]; NSDTA * Metawals = [Graphical Data UDP encoding: NSISLTin1 string encoding];  

Since I have created the particle string using alloc, I thought I need to release it after converting it to NSDT, so I added

 

But when I add this line my app crashes, however, when I extract that line where I use it to make metaways, then I can secure it I can release the form.

Can anyone explain why passing it to NSDT is prevented from issuing it to me? I believe my particle is straightening, what's going on?

According to your comment, "Some other string"]; which loses the context of the original particle string, and replaces it with an autoreled version, then you go to release the autorelase version, due to the leak of the original particle string, and an overlay of the new Because of both

  NSString * particleString = [NSString stringWithFormat: @ "% @", @ "This is the main part of my file"]; Particle string = [particle string stringbending formatting: @ "% @", @ "some other string"]; NSDTA * Metawals = [Graphical Data UDP encoding: NSISLTin1 string encoding];  

There is no longer a release because both the strings are now autorespages.

I


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -