Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > subclassing NSScanner - what am I doing wrong?

subclassing NSScanner - what am I doing wrong?
Thread Tools
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Mar 30, 2003, 03:49 PM
 
here's what I have:
Code:
#import <Foundation/Foundation.h> #import <Cocoa/Cocoa.h> @interface tScanner : NSScanner { } - (BOOL)scanPast:(NSString *)string; @end #import "tScanner.h" @implementation tScanner - (BOOL)scanPast:(NSString *)string { if (![self scanUpToString:string intoString:nil]) return NO; if (![self scanString:string intoString:nil]) return NO; return YES; } @end
and the program seems to get by
tScanner *scan = [[tScanner alloc] initWithString:];
but it crashes on the first scanUpToString:intoString:
if I switch it back to NSScanner, it works fine. I know I've subslcassed NS classes successfully before....someone throw me a bone please

PS. obviously it would be easier to do this the long way with NSScanner, but I hope to expand to other conveniences once I get this working
     
lfrog2
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Apr 1, 2003, 11:19 AM
 
NSScanner is a class cluster, which you have to subclass differently. There is some documentation at developer.apple.com, or on your hard drive. Unfortunately, I do not remember where. If you do an archive search at http://cocoa.mamasam.com you should find some posts on the subject.

Also, did you consider using a category instead? This seems like it would be much easier.
     
asd
Fresh-Faced Recruit
Join Date: Sep 2001
Status: Offline
Reply With Quote
Apr 3, 2003, 04:50 PM
 
If u want to extend a class but not add any instance variables, using a category is much easier.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:04 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,