• 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: figuring out the length of a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: figuring out the length of a string


  • Subject: Re: figuring out the length of a string
  • From: "Mark A. Stratman" <email@hidden>
  • Date: Fri, 25 Jun 2004 01:51:27 -0500

On Jun 24, 2004, at 4:22 PM, John Spicer wrote:

I know it's a stupid question, and I'm embarased to ask, but I've been going through the docs for an hour and can't find it.

I'm loading some data from a database via web services, some of the fields are nulls. The string is set to a CFNull in that case.

I'd like to filter on this somehow and return a blank string instead.

I have found an example on apple's site that using the [mystring length] == 0 to test for this, but xcode does not like this.

You mentioned using web services and CFNull, which means you're probably working with CFString's?
If so, you won't (as far as I know, somebody correct me if I'm wrong - too lazy to test atm) be able to treat it as an NSString ("[mystring length]" is objective C, calling the length method on an NSString). The toll-free bindings work as far as treating an NSString as a CFString, but I don't think it works the other way around.

So (again, assuming this is the case) if you want to use it as an NSString, try: NSString newString = [NSString stringWithString:mystring];
Then use [newString length].
Or, use the Core Foundation functions for CFString instead. CFStringGetLength(mystring);

hth
- mark
_______________________________________________
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.


  • Follow-Ups:
    • Re: figuring out the length of a string
      • From: "Louis C. Sacha" <email@hidden>
    • Re: figuring out the length of a string
      • From: Chris Ridd <email@hidden>
References: 
 >figuring out the length of a string (From: John Spicer <email@hidden>)

  • Prev by Date: Re: Cocoa Java resources?
  • Next by Date: Re: figuring out the length of a string
  • Previous by thread: Re: figuring out the length of a string
  • Next by thread: Re: figuring out the length of a string
  • Index(es):
    • Date
    • Thread