On May 10, 2008, at 2:26 PM, Lincoln Green wrote:

- (NSRange)wordRangeForRange:(NSRange)range{
NSString *string = [NSString stringWithString:[[self string] substringWithRange:range]];
        if([string hasPrefix:@" "]){
[string stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@""];

Not sure why the above line is here, you are not using string after this so why are you changing it?


                range.location++;
        }
        NSString *op = [NSString stringWithString:[self string]];
        int length = range.location;
        int finished = 0;
        while(finished != 1){                                                   
        //2
                if([op substringWithRange:NSMakeRange(length, 1)] == @" "){

try isEqualToString: instead of ==


                        finished = 1;
                }else{
                        NSLog([op substringWithRange:NSMakeRange(length, 1)]);  
//1
                        length++;
                }
        }
        range.length = length;
        return range;   
}

This code is in an NSTextView subclass.

Can anyone tell why it would not work as a wordRangeForRange: implementation? When I run it, my loop at //2 doesn't stop until "length" exceeds my character count, even though at //1, My console logs a space. Any suggestions? Also, if this is not clear, post in and I will try to explain it more clearly.

Thanks!


Lincoln Green
[EMAIL PROTECTED]
http://www.binkworks.com/

--Nathan
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to