objective c - Get an object's memory address as a long/long long? -



objective c - Get an object's memory address as a long/long long? -

what need pretty straightforward :

the same way can nslog("%@",someobject); or nsstring* hex = [nsstring stringwithformat:@"%p",someobject]; print hex value of someobject's memory address, want number variable (to utilize unique identifier).

any thought how done? built-in methods?

others showed how integer value of adress, want add together som considarations.

as long object lives, pointer unique. , sson, object get's deallocated, there no utilize unique identifier derived pointer anymore. infact might harm, if have identifier allocated object address re-used.

better maintain track of object adding collection or adding guaranteed unique id object itself. uuids selection that.

an implementation that:

-(nsstring *)uuid { cfuuidref uuid = cfuuidcreate(kcfallocatordefault); nsstring *uuidstr = (__bridge_transfer nsstring *)cfuuidcreatestring(kcfallocatordefault, uuid); cfrelease(uuid); homecoming uuidstr; }

objective-c cocoa

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -