• 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: Simple CFString ref question (take pity on ObjC dude)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple CFString ref question (take pity on ObjC dude)


  • Subject: Re: Simple CFString ref question (take pity on ObjC dude)
  • From: Guy English <email@hidden>
  • Date: Sat, 18 Mar 2006 19:05:11 -0500

On 18-Mar-06, at 6:33 PM, Steve Cronin wrote:
      theParameters.p1      = CFSTR("String1");
      theParameters.p2      = CFSTR("TString2");

What I want to do is change it to something close to:
theParameters.p3 = [[NSString stringWithFormat:@"%@",newVal] cStringUsingEncoding:[NSString defaultCStringEncoding]];

theParameters.p3 = (CFStringRef)[NSString stringWithFormat: @"%@", newVal];


NSString objects and CFStringRefs are essentially the same thing so you can use them interchangeably.

Note though that in the code snippet you show the first two params will be around for the life of the app (since they're statically allocated) but the return value of [NSString stringWithFormat: ...] is autoreleased. This will only matter if you're planning on keeping theParameters around from longer than the current pass through the runloop.

Take care,
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Simple CFString ref question (take pity on ObjC dude) (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: Interapp communication
  • Next by Date: Re: classes in framework
  • Previous by thread: Re: Simple CFString ref question (take pity on ObjC dude)
  • Next by thread: Re: classes in framework
  • Index(es):
    • Date
    • Thread