0

If I allocated memory for any objects, sometimes I must run deallocate. But if I declare variable (for example NSString) and don't allocate as below:

NSString* myStr = [NSString stringWithContentsOfFile:@"file.xml" ....];

Why I catch error if I try deallocate this?

Ilya Ilin
  • 2,283
  • 21
  • 27

1 Answers1

1

stringWithContentsOfFile is a convenience method of NSString that takes care of it.

See this answer for an explanation of what you do and do not need to release.

Community
  • 1
  • 1
Matthew Frederick
  • 22,245
  • 10
  • 71
  • 97