Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:26:39+00:00 2026-06-09T06:26:39+00:00

I made a textview that is bulleted only. It works just like a bulleted

  • 0

I made a textview that is bulleted only. It works just like a bulleted list in word. Now I am making an array using this code to separate strings by a bullet point (\u2022)

//get the text inside the textView
NSString *textContents = myTextView.text;

//make the array
NSArray *bulletedArray = [textContents componentsSeparatedByString:@"\u2022"];

//print out array 
NSLog(@"%@",bulletedArray);  

It works perfectly with separating the text into components by bullet points but it keeps the first line that has nothing in it. So when it prints out it looks like this.

"",
"Here is my first statement\n\n",
"Here is my second statement.\n\n",
"This is my third statement. "

The very first component of the array is “” (nothing). Is there a way to avoid adding components that equal nil?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:26:42+00:00Added an answer on June 9, 2026 at 6:26 am

    Sadly, this is the way the componentsSeparatedBy... methods of NSString work:

    Adjacent occurrences of the separator characters produce empty strings in the result. Similarly, if the string begins or ends with separator characters, the first or last substring, respectively, is empty.

    Since you know that the first element will always be empty, you can make a sub-array starting at element 1:

    NSArray *bulletedArray = [textContents componentsSeparatedByString:@"\u2022"];
    NSUInteger len = bulletedArray.count;
    if (bulletedArray.count) {
        bulletedArray = [bulletedArray subarrayWithRange:NSMakeRange(1, len-1)];
    }
    

    Alternatively, you can use substringFromIndex: to chop off the initial bullet character from the string before passing it to the componentsSeparatedByString: method:

    NSArray *bulletedArray = [
        [textContents substringFromIndex:[textContents rangeOfString:@"\u2022"].location+1]
        componentsSeparatedByString:@"\u2022"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a layout that is just simply a textview that says What do
I've made a database that has information like this http://i170.photobucket.com/albums/u244/therealbbri06/database.jpg and I'm trying to
Made this nice little loop for hiding and showing div's, works as a charm
Html List tag not working in android TextView. This is my string content: String
I just wrote some code. It has my own custom made class. In that
So i have this listview with my custom XML file that i made for
So, I have this nice little view that I've made, which basically shows two
I've made a simple Android music player. I want to have a TextView that
I made an iphone app to capture image from camera and to set that
I made an application that passes trough an XML file and extracts the entries

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.