user891268
user891268

Reputation: 1425

What happens if I release a non-allocated object?

What happens if I release a non-allocated object?

Example:

NSString *value = @"hello World!";

[value release]; 

Upvotes: 3

Views: 133

Answers (2)

Rudy Velthuis
Rudy Velthuis

Reputation: 28806

As sydill said, string literals are different, as they don't need to be allocated or released.

Releasing other non-allocated objects OTOH, also NSStrings that are not literals, will very likely cause an EXC_BAD_ACCESS exception.

Upvotes: 1

sidyll
sidyll

Reputation: 59287

Nothing, string literals are special when it comes to memory management. Check this question.

Upvotes: 2

Related Questions