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?
stringWithContentsOfFileis 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.