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 7928549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:45:49+00:00 2026-06-03T19:45:49+00:00

I have a really long string, with thousands of line with a default font.

  • 0

I have a really long string, with thousands of line with a default font. So rather than draw the whole thing out in one table view cell, I’m going to make several cells to draw the same string, each drawing the next part of the string.

I’m having a hard time finding a starting point. Say I draw the first 500 pixels of height of the string in the rect – how do I know where to start in my second rect? If it’s the same string, how can I specify for it to draw only some parts of the string?

Each cell will know it’s own row number, so I’ll be able to determine where exactly in the table I am, I just don’t know how the string will know which part it’s supposed to draw..

Or another question would be: how can I break up one string into multiple strings based on a certain number of lines?

Edit: Here are some NSString methods I’m finding that might be useful, but I still don’t know how I would use them in my case:

- (void)getLineStart:(NSUInteger *)startIndex end:(NSUInteger *)lineEndIndex contentsEnd:(NSUInteger *)contentsEndIndex forRange:(NSRange)aRange
- (NSRange)lineRangeForRange:(NSRange)aRange
  • 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-03T19:45:50+00:00Added an answer on June 3, 2026 at 7:45 pm

    Use substringWithRange: This will allow you to select a start and end point of the string. I would grab each section by a number of characters. So section 1 would be 0-500 section 2 would be 500-1000. The problem here would be you may cut off in the middle of a sentence. You can use something like lineRangeForRange to determine your ranges for the substring.

    lineRangeForRange
    Returns the range of characters representing the line or lines containing a given range.
    
    - (NSRange)lineRangeForRange:(NSRange)aRange
    Parameters
    aRange
    A range within the receiver.
    Return Value
    The range of characters representing the line or lines containing aRange, including the line termination characters.
    

    EDIT

    NSString *string = @"tjykluytjghklukytgjhkkghkj sdkjlhfkjsadgfiulgeje fuaeyfkjasdgfueghf aksjgflkj. wyruehskjluishfoeifh uasyeajhkfa uiyelkjahsdf uayekljshdf aehkfjsd. \n I iheio;fajkdsf sdfhlueshkfjskdhf ujhelkjfh. luehljkfhlsdf. leufhlkjdshfa. \n euoiywhfldsjkhf euyhfsdlkj. ewhlkjfsd. euilhfsdkjishdkjf euhjklsfd. \n";
    NSLog(@"string length:%i", [string length]);
    NSRange range;
    range.length = [string length]/2;
    range.location = 0;
    NSLog(@"LineRangeForRange:%i", [string lineRangeForRange:range].length);
    NSLog(@"Substring:%@", [string substringWithRange:[string lineRangeForRange:range]]);
    

    Log displays:

    string length:295
    LineRangeForRange:148
    Substring:tjykluytjghklukytgjhkkghkj sdkjlhfkjsadgfiulgeje fuaeyfkjasdgfueghf aksjgflkj. wyruehskjluishfoeifh uasyeajhkfa uiyelkjahsdf uayekljshdf aehkfjsd.
    

    So what this did was I supplied LineRangeForRange a range which was from zero to half of the string. It could the last end line “\n” with in that range. Then I grabbed that substring

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather long switch-case statement. Some of the cases are really short
I have a sql data source and I have a really long string of
I have a really long string that I need to pass in a URL,
Well i have a long string in double quotes var Variable = Really Long
I have a really long string. I would like to add a linefeed every
I have a really long string of text that I would like to update
I have a really long string in python: long_string = ' this is a
I have a really long string (reallyLongString below) and want to put its declaration/definition
How can I truncate string in JSF2 ? Say I have a really long
I have a really long string, I just want to extract some certain string

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.