Can a method return an NSRange?
- by Dan Donaldson
I have a method that returns an NSRange. When I call this method from outside the class I get a compile error.
NSRange tmpRange;
tmpRange = [phrase rangeInString:searchString forString:theLetter goingForward:YES];
return tmpRange.location == -1;
in the .h file:
#import <Foundation/Foundation.h>
@interface Phrase : NSObject {
}
- (NSRange) rangeInString:(NSString *) tgt forString:(NSString *) find goingForward:(BOOL) fwd;
@end
This method is called within the Phrase object by other methods without problems. The compiler says 'incompatible types in assignment'.
Can anyone explain this to me? I assume it has to do with returning an NSRange/struct type value generated outside the object, but I don't know why it works in one place and not the other.