• 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: C string conversions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C string conversions?


  • Subject: Re: C string conversions?
  • From: Michael McCracken <email@hidden>
  • Date: Wed, 13 Jul 2005 13:57:27 -0700

Another link - I haven't scanned the intro docs for a while, they have
made some nice improvements. You might actually want to start here:

http://developer.apple.com/referencelibrary/GettingStarted/GS_Cocoa/index.html

That page gives you links to docs you need to read based on where
you're coming from and what you want to do - nice.

-mike

On 7/13/05, Michael McCracken <email@hidden> wrote:
> Welcome, Charles.
>
> any method that starts with 'init...' is an instance method, so you do
> need to allocate an object first - in your case you want this:
>
> [[NSAttributedString alloc] initWithString:[NSString
> stringWithCString:cstringgoeshere]]
>
> if NSAttributedString had a + attributedStringWithString: class
> method, that'd do what you want, but it doesn't, so you have to do it
> this way.
>
> Note that since you've created an object and initialized it yourself,
> you own it - It has a retain count of 1 now and you will have to
> release or autorelease it or it will be a leak once you're no longer
> using it.
>
> A quick intro read might be in order - the conceptual docs are
> definitely worth the time, and don't really take as long to read as it
> seems:
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaObjects/index.html
>
> HTH,
> -mike
>
> On 7/13/05, Charles Turner <email@hidden> wrote:
> > Hi all-
> >
> > New to Cocoa and the list, and of course had a question:
> >
> > I have an instance method in an object I've written that has a C string
> > as an argument. I need to store this in a TextStorage object, currently
> > using appendAttributedString:
> >
> > Any thoughts on conversion? Right now I'm trying:
> >
> > [NSAttributedString initWithString: [NSString stringWithCString:
> > aString]]
> >
> > but initWithString isn't a class method, so it looks like I would have
> > to create an instance of NSAttributedString...
> >
> > Anyway, thanks in advance if anything strikes you.
> >
> > Best,
> >
> > Charles Turner
> >
> > <email@hidden>
> >  _______________________________________________
> > 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
> >
>
>
> --
> Michael McCracken
> UCSD CSE PhD Candidate
> research: http://www.cse.ucsd.edu/~mmccrack/
> misc: http://michael-mccracken.net/blog/
>


--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/blog/
 _______________________________________________
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: 
 >Re: C string conversions? (From: Michael McCracken <email@hidden>)

  • Prev by Date: Re: Core Data/Cocoa Bindings: best practice for using strings in code?
  • Next by Date: NSNotificationCenter possible memory leak? [for memory geek]
  • Previous by thread: Re: C string conversions?
  • Next by thread: Re: C string conversions?
  • Index(es):
    • Date
    • Thread