Why "cannot use an object as a parameter to a method"?
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2009-05-10T20:32:02Z
Indexed on
2010/06/18
5:03 UTC
Read the original article
Hit count: 270
objective-c
I have the following ViewController class
#import <UIKit/UIKit.h>
@interface SampleViewController : UIViewController {
IBOutlet UITextField *field1;
}
@property (nonatomic, retain) UITextField *field1;
- (IBAction) method1:(id)sender;
@end
When I change the method1:(id)sender to method1:(UITextField)sender, I get the error "Cannot use an object as a parameter to a method".
I searched and found this post which says "it [using an object as a method parameter] is not a good idea in Objective-C because Objective-C does not allow statically allocated object".
Can anyone point out where I can find a more detailed explanation for this?
Thank you.
© Stack Overflow or respective owner