Memory management questions using UUID example
Memory management questions using UUID example
- Subject: Memory management questions using UUID example
- From: Brian Gilman <email@hidden>
- Date: Sun, 19 Jan 2003 11:57:09 -0500
On 1/19/03 1:33 AM, "Joseph Jones" <email@hidden> wrote:
Hello all,
Two (perhaps stupid) questions:
I'm very new to cocoa but not to c/c++. I'm still having some
conceptualization problems when it comes to memory management. Forgive me if
these questions sound stupid but, I need to clear some things up in my mind
so I don't mess things up in my own apps!!
1) Why do you need to cast the uuisStr twice in this method??
2) When you call [(NSString *)uuidStr autorelease]; does this put allow
the runtime to handle reference counting??
I guess the real question is when do I do an [[alloc] init] and when I
do an [Object* autorelease]??
It this the same as using dyn_pointers in C++?? And, finally, is there
clear, concise documentation on mem management in Cocoa??
Best,
-B
>
Works like a charm.
>
>
Thanx,
>
joe
>
>
On Saturday, January 18, 2003, at 10:11 PM, Scott Anguish wrote:
>
>
>
>
> On Saturday, January 18, 2003, at 11:37 PM, Joseph Jones wrote:
>
>
>
>> Is there a set of API's or objects in Cocoa that generate and work
>
>> with UUIDs? After a LONG while of digging around I located Carbon
>
>> APIs for this, but I'd like to stick to Obj C and Cocoa as much as >
>
>> possible.
>
>>
>
>
>
> I've used this category for making UUID strings
>
>
>
>
>
> @implementation NSString(uuid)
>
>
>
> + (NSString *)uniqueString
>
> {
>
> CFUUIDRef uuid = CFUUIDCreate(NULL);
>
> CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);
>
> CFRelease(uuid);
>
> [(NSString *)uuidStr autorelease];
>
> return (NSString *)uuidStr;
>
> }
>
>
>
> @end
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
>
--
Brian Gilman <email@hidden>
Group Leader Medical & Population Genetics Dept.
MIT/Whitehead Inst. Center for Genome Research
One Kendall Square, Bldg. 300 / Cambridge, MA 02139-1561 USA
phone +1 617 252 1069 / fax +1 617 252 1902
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.