NSTextList - need help

Discussion in 'Mac Programming' started by rethish, Dec 18, 2008.

  1. rethish macrumors member

    Oct 16, 2008
    hi all,

    I would like to use bullets and numberings in the textview .
    I found some of search results for this topic ,they were about NSTextList .
    How can it be used.

    please provide me some help on NSTextList.

    thank you
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Have you looked at the documentation? It describes how to use it.
  3. rethish thread starter macrumors member

    Oct 16, 2008

    I had referred the documentation. I managed to understand a little concepts by referring some examples from websites. Now the task is partially done .

    But the problem now is , this bullets and numberings works only if there is no contents(text) in the textview.

    i want to use bullets and numberings to text that is already been typed , likewise in textedit

    the code is :

    if([[popupbutton titleOfSelectedItem] isEqualToString:mad:"-" ])
    NSTextStorage *storage=[textview textStorage];

    [storage beginEditing];
    NSMutableAttributedString *text = [[NSMutableAttributedString

    NSMutableParagraphStyle *mps = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
    NSTextList *listItem = [[NSTextList alloc] initWithMarkerFormat:mad:"{hyphen}" options:NSTextListPrependEnclosingMarker];
    [mps setTextLists:[NSArray arrayWithObject:listItem]];
    NSMutableString *tabs = [@"\t" mutableCopy];

    [tabs appendString:mad:"\t"];

    [text appendAttributedString: [[NSAttributedString alloc]
    initWithString:[NSString stringWithFormat:mad:"\t%@\t", [listItem markerForItemNumber:1] ]
    attributes:[NSDictionary dictionaryWithObject:mps
    [storage setAttributedString:text];
    [storage endEditing];


    please provide me some tips to overcome this problem


Share This Page