Default insertText:(id)sender autotype 3.2.1 Xcode


#1

Just a point of curiosity…

When I first typed

-(void) insertText : " (id)sender" popped up in the auto type not (NSString *)textString

should we be using (id)sender ??? how would we use (id)sender???
Just curious… is this new to 3.2???

Thanks
Ian


#2

[quote=“IanDMah”]Just a point of curiosity…

When I first typed

-(void) insertText : " (id)sender" popped up in the auto type not (NSString *)textString

should we be using (id)sender ??? how would we use (id)sender???
Just curious… is this new to 3.2???

Thanks
Ian[/quote]

I guess that’s because the generic (I’m assuming we’re getting this from NSResponder?!) method we’re overwriting was written to take both an NSString and/or an NSAttributedString object, so using id makes sense, see developer.apple.com/mac/library/ … C/ObjC.pdf

“In Objective-C, object identifiers are a distinct data type: id. This is the general type for any kind of object regardless of class. (It can be used for both instances of a class and class objects themselves.) […] All objects, regardless of their instance variables or methods, are of type id.” This is also what makes Dynamic Typing possible…

But anyway, since we know we’ll only ever get an NSString * and the compiler can catch errors more easily when “real” types are used, I’d rather use that

HTH