user2626382
user2626382

Reputation: 85

Memory management of returned structs using ARC in Objective-C

Am I supposed to explicitly free memory when I get a struct returned from a function such as NSMakeRange() when using ARC in Objective-C?

Upvotes: 1

Views: 164

Answers (1)

user529758
user529758

Reputation:

No. You couldn't even do that either. It's not an object, it's not something allocated using malloc(), nothing like that. It's a primitive value that gets copied whenever necessary and vanishes when its scope ends.

when using ARC in Objective-C?

Yes. And when not using it. It doesn't matter - ARC and MRC are concerned with Objective-C objects only. Not with those with automatic storage duration, not with those allocated by the C standard library functions.

Upvotes: 3

Related Questions