Shortest Solution for Challenge Question


#1

.h file

@interface myClass : NSObject { IBOutlet NSTextField *textField; IBOutlet NSTextField *labelField; } -(IBAction)setString:(id)sender; @end

.m file

-(IBAction)setString:(id)sender { NSUInteger len = [[textField stringValue] length]; NSString *str1 = [NSString stringWithFormat:@"%d",len]; [labelField setStringValue:str1]; }


#2

Thats all it takes?

Why was I killing myself to allocate and initialize if I didn’t need to?

Why do I not need to do those things?

:laughing:

:frowning:


#3

You can actually do the .m as a one liner (with similar declarations in the .h). I don’t know if there are any inherent problems with this method as I am only up to this chapter.