Re: Help with "Messages without a matching method signature..." issue
Re: Help with "Messages without a matching method signature..." issue
- Subject: Re: Help with "Messages without a matching method signature..." issue
- From: Charles Steinman <email@hidden>
- Date: Tue, 22 Jul 2008 12:41:13 -0700 (PDT)
-sendMSG:toPort: is an instance method, which should be sent to an object. You are sending it to Class2, which is a class rather than an instance of that class.
Cheers,
Chuck
--- On Tue, 7/22/08, Brad Gibbs <email@hidden> wrote:
> From: Brad Gibbs <email@hidden>
> Subject: Help with "Messages without a matching method signature..." issue
> To: "Cocoa List" <email@hidden>
> Date: Tuesday, July 22, 2008, 12:28 PM
> I read the Newbie Question on a method signature thread from
> June 4 a
> few times, but, either that isn't the problem I'm
> having, or I'm not
> understanding the solution...
>
> Any help would be greatly appreciated.
>
>
> On compile, I get the following warnings:
>
> warning: 'Class2' may not respond to
> '+sendMSG:toPort:'
> warning: (Messages without a matching method signature will
> be assumed
> to return 'id' and accept '...' as
> arguments.
>
>
>
> And clicking a button produces the following in the
> Console:
>
> 2008-07-22 11:03:06.824 OSX Interface[37304:10b] ***
> +[Class2
> sendMSG:toPort:]: unrecognized selector sent to class
> 0x4080
>
>
>
> Below is the offending code:
>
> Class 1 - This class provides IBActions, each of which
> calls the
> sendMSG: toPort: method of Class 2. The arguments for the
> methods in
> this class are used to construct NSStrings in Class 2.
> Class 2 - The arguments sent from a button in Class 1
> provide two
> strings, which are used to compose a new NSString, which is
> sent to
> another device on the network.
>
>
> @interface Class1 : NSObject {
> }
> - (IBAction)powerOn:(id)sender;
>
>
> @implementation Class1
>
> - (IBAction)powerOn:(id)sender {
> [Class2 sendMSG:@"P1P1" toPort:@"1"];
>
>
> @interface Class2 : NSObject {
> }
>
> - (NSString *)sendString:(NSString *)stringToSend;
> - (void)sendMSG:(NSString *)string toPort:(NSString *)port;
>
> @implementation Class2
>
> - (NSString *)sendString:(NSString *)stringToSend {
> NSData *postData = [stringToSend
> dataUsingEncoding:NSASCIIStringEncoding
> allowLossyConversion:YES];
> NSString *postLength = [NSString
> stringWithFormat:@"%d", [postData
> length]];
>
> NSMutableURLRequest *theRequest=[[[NSMutableURLRequest
> alloc] init]
> autorelease];
> ...
>
> response = [[NSString alloc] initWithData:receivedData
> encoding:NSASCIIStringEncoding];
> return response;
> }
>
>
> - (void)sendMSG:(NSString *)string toPort:(NSString *)port
> {
> NSString *stringToSend;
> stringToSend = [[NSString alloc]
> initWithFormat:@"method=MSGSend¶m1=%@¶m2=%@¶m3=200",
> port,
> string];
> NSLog(@"String being sent: %@", stringToSend);
> [self sendString:stringToSend];
> }
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to
> the list.
> Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden