I have an NSLayoutManager, two NSTextContainers, and an NSTextStorage object.
I add strings one by one to the textStorage object until the first textContainer is full, then I use the amount of text added to that textContainer draw a page in my book app.
99% of the time the isAtEnd flag in didCompleteLayoutForTextContainer will tell me when the first text container got full.
However, in a rare case, if I add a string to the textStorage it will actually remove text from the first text container!
For example, when the first text container has this string in it (and is almost full):
\n\n\n\n\n\nMexico \n\nBook Covers from Germany \n\n \n\n \n\n Book Covers from Germany Special Edition \n\nBook Covers from Denmark Sweden \n\nBook Covers from Japan \n\nBook Covers From Finland \n\nBook Covers From Greece
if I add this string to the textStorage:
Spain \n\nBook Covers From Iceland \n\nBook Covers From Netherlands \n\nBook Covers from Norway
the layoutManager will move the word "Greece" from the first textContainer and move it to the second textContainer.
I would have rather had the layoutManager tell me that the first textContainer was full before I attempted to add a new string and have it do this unexpected behavior.
Can anyone tell me why this is happening? or tell me how I can tell when this will happen again so that I can figure out when the first textContainer is really full?
Thanks!