• 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
NSString -componentsSeparatedByString: line break
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSString -componentsSeparatedByString: line break


  • Subject: NSString -componentsSeparatedByString: line break
  • From: Chase Meadors <email@hidden>
  • Date: Sun, 26 Jul 2009 20:57:44 -0500

Say I have a string that looks like this

----
Hello. How are you?
This is the second line.

Fourth line.
----

I'm trying to get each line of the reciever by calling

[string componentsSeparatedByString:@"\n"];

This works fine, but assuming the string is actually laid out like this:

Hello. How are you?\nThis is the second line.\n\nFourth line.

The array contains

@"Hello. How are you?"
@"This is the second line."
@"" (???)
@"Fourth line."

The third line is what I'm having problems with. I would think it would simply be an empty string @"". But,

Both of these:

[stringInQuestion isEqualToString:@""]; //outputs false
[stringInQuestion isEqualToString:@" "]; //also outputs false

output false. Even more puzzling, this

[stringInQuestion length] //outputs 1

outputs 1.

If the length of this mystery string is 1 and it's not a space, what is it???

Any help appreciated!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Passing data between NSOperation and main thread
  • Next by Date: NSCoder Chicago Reminder Monday Night
  • Previous by thread: Re: Problems with japanese characters
  • Next by thread: Re: NSString -componentsSeparatedByString: line break
  • Index(es):
    • Date
    • Thread