This will work:
char *types = [[NSString stringWithFormat:@"v@:%s@", @encode(NSRect)] UTF8String];
BOOL success = class_addMethod(NSClassFromString(@"MyClass"),
@selector(drawWithFrame:inView:),
(IMP)drawWithFrameInView,
types);
, , , NSRect , typedef - struct.
.