wordRangeForRange implememtation
wordRangeForRange implememtation
- Subject: wordRangeForRange implememtation
- From: Lincoln Green <email@hidden>
- Date: Sat, 10 May 2008 15:26:26 -0500
- (NSRange)wordRangeForRange:(NSRange)range{
NSString *string = [NSString stringWithString:[[self string]
substringWithRange:range]];
if([string hasPrefix:@" "]){
[string stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:@""];
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)] == @" "){
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@hidden
http://www.binkworks.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden