• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: NSStrings obtained from CFStrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSStrings obtained from CFStrings


  • Subject: RE: NSStrings obtained from CFStrings
  • From: "ROSE,ROBERT W (HP-Corvallis,ex1)" <email@hidden>
  • Date: Thu, 3 Apr 2003 13:12:27 -0800

Right, but what about getting CFStrings? Are they any different?

I did some testing yesterday evening... After I got the CFString I did a
CFGetRefCount() on it, and the return value was 1. This helps, but I still
don't know if the string was marked for "autorelease" or not.

Is this code "correct"?

-(NSString *)dosomething
{
NSString *string = (NSString *) CFXMLNodeGetString(blah);
return [[string retain] autorelease];
}

-(void)setString:(NSString *)newstring
{
if(newstring != string) {
[string release];
string = [newstring copy];
}
}

[self setString: [theobject dosomething]];

?

-robert

-----Original Message-----
From: Wesley Miaw [mailto:email@hidden]
Sent: Thursday, April 03, 2003 9:17 AM

The convention suggested by Apple is to have whoever did the explicit
alloc, copy, or retain to be responsible for releasing it. e.g.
[NSArray arrayWithCapacity:x] would have been returned to you with
autorelease, but [[NSArray alloc] initWithCapacity:x] is your
responsibility to release.

On Thursday, April 3, 2003, at 01:00 AM,
email@hidden wrote:

> My question is, if I have a utility function that takes a CFTreeRef and
> returns the NSString value of that node, what's the "kosher" way to do
> this?
> Should I "retain" the string and then return it? Can you "retain" a
> CFString? Here's what I mean:
>
> NSString *string = (NSString *) CFXMLNodeGetString(blah);
> return [[string retain] autorelease];
>
> When the CFString comes out of CFXMLNodeGetString() what's it's
> refcount?
- --
Wesley Miaw, Wesley Miaw Consulting
http://www.wesman.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)

iD8DBQE+jGyOQv4agqRAk2kRAtnSAKCt+csyg8R22QnS57m5DwPAX1p/wACfTUai
5Tz86FjtGiaYqgNiLxGzw5g=
=iQDH
-----END PGP SIGNATURE-----
_______________________________________________
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.
_______________________________________________
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.

  • Prev by Date: Re: hasSuffix and new line characters.
  • Next by Date: nspopupbutton smoothness
  • Previous by thread: Re: NSStrings obtained from CFStrings
  • Next by thread: Re: NSStrings obtained from CFStrings
  • Index(es):
    • Date
    • Thread