0

Say you have class Block

Class Block : NSObject

Now, you want to create array in C-style

Block *blocks[5]; // or calling malloc()
Block *aBlock = [[Block alloc] init];
blocks[0] = aBlock; 
// at this point, aBlock will be hand over to array blocks slot.
// not like NSArray, object of 'Block' will not retain by @property(retain)
// or should I call retain before hand over the value into its array and release afterward?
// should I still call below code to release object ?
// [aBlock release];

Can someone explain to me should I still need to release the aBlock object afterward?

1
  • 1
    If you did this under arc, you would only have to set the objects in the array to nil when you were done, and not have to worry about this. Commented Oct 17, 2012 at 3:54

1 Answer 1

2

No because the primitive array won't be retaining each Block object. So if you release it, all Block objects will be cleaned up the moment the function exits scope

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.