Re: Problems with NSTextField and attributed strings
Re: Problems with NSTextField and attributed strings
- Subject: Re: Problems with NSTextField and attributed strings
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 21 Jul 2004 16:55:56 -0700
Hello...
That still won't remove all of the tab stops since the loop won't be
run enough times (because even though it removes the first object in
the array instead, i is still being incremented and count is being
decremented each time through the loop).
You can use an NSEnumerator to feed a while loop:
NSEnumerator *tabEnumerator = [[style tabStops] objectEnumerator];
id currentTab = nil;
while ((currentTab = [tabEnumerator nextObject]))
{
[style removeTabStop:currentTab];
}
You can get the count outside of the for loop and use the stored
value for the check:
unsigned i, tabCount = [[style tabStops] count];
for (i=0; i < tabCount; i++)
{
[style removeTabStop:[[style tabStops] objectAtIndex:0]];
}
You can use the count as the test for a while loop:
while ([[style tabStops] count] != 0)
{
[style removeTabStop:[[style tabStops] objectAtIndex:0]];
}
Hope that helps,
Louis
At 1:16 PM -0500 7/21/04, Tim Cartwright wrote:
...
The log statement confirms the intent to remove 12 tab stops.
However, debugging output immediately following this code shows
that my two tab stops are followed by 6 other tab stops, starting
at 56.0 points and every 56.0 points thereafter. Why? I even
added this line of code:
Try:
for (i = 0; i < [[style tabStops] count]; ++i)
{
[style removeTabStop: [[style tabStops] objectAtIndex: 0]];
}
since your code otherwise only removes the first half the tabStops
(since it'll stop when i = count, which gets decremented each time
through your loop).
--
Glenn Andreas email@hidden mondo
blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.