- (void)deleteCharactersInRange:(NSRange)aRange, Where I went wrong
- (void)deleteCharactersInRange:(NSRange)aRange, Where I went wrong
- Subject: - (void)deleteCharactersInRange:(NSRange)aRange, Where I went wrong
- From: Mark Ogilvie <email@hidden>
- Date: Tue, 4 Mar 2003 21:03:16 -0500
Actually I went wrong in a lot of places, but the two that most come to
mind are:
1, I was confused by the fact that NSRangeSpecifier was the only range
in the class methods list, I had no idea the ranges might exist as
functions. (Thanks Mr. Dobbie and Alex). The fact that
NSRangeSpecifier existed on the first list I have bookmarked and I
hadn't noticed yet that there was a function list was a lot of my
problem. All I could see was the Range in the heading NSRangeSpecifier
and I got dead-ended on that point.
2, I had overlooked the fact that, as told on page 53 of the Learning
Cocoa book, "Nested messages work only when the inner expression
returns on object value." So I didn't realize that the line in my
program that depended on ranges wouldn't have worked anyway.
Oh well, I've got time, the book and the mac, I'll learn.
In the meantime this is the program I worked up just to work all this
up for myself.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableString * test =[[NSMutableString alloc]init];
[test appendString:@"This is a test string."];
printf("%s\n", [test UTF8String]);
// make range, go to the end of the string, come back 8, 2 is what
will be eliminated.
NSRange mRange = NSMakeRange(([test length]-8),2);
printf("%i\n", [test length]);
printf("range.length %i\n", mRange.length);
printf("range.location %i\n", mRange.location);
[test deleteCharactersInRange:mRange];
printf("%s\n", [test UTF8String]);
printf("%i\n", [test length]);
[pool release];
return 0;
}
It works, now I'll get some sleep.
Thanks
Mark
http://members.ttlc.net/~mso/WebPage1.html
_______________________________________________
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.