objective c - Manually deallocating NSValue -


is possible instantiate nsvalue pointer c structure without having create autorelease pool? moment, this:

nsvalue* val = [nsvalue valuewithpointer:(const void*)structure]; 

but release autorelease pool. take control of , able dealloc when want. possible? tried this:

nsvalue* value = [[nsvalue alloc] initwithbytes:(const void*)structure objctype:@encode(const void*)]; [value release]; 

but crashing reason. other way able release immediately? thanks!

you're supposed passing pointer type that's given objctype: argument. you're passing variable of type. so, example, if have variable int foo want store in nsvalue, you'd write [[nsvalue alloc] initwithbytes:&foo objctype:@encode(int)]. if want store pointer, need pass pointer pointer bytes. passing pointer cause nsvalue try follow pointer , treat bytes it's pointing pointer well.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -