• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why does [someObj msgA:@"xyx"] not give my expected result
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does [someObj msgA:@"xyx"] not give my expected result


  • Subject: Re: Why does [someObj msgA:@"xyx"] not give my expected result
  • From: "stephen joseph butler" <email@hidden>
  • Date: Thu, 29 Nov 2007 01:22:43 -0600

On Nov 29, 2007 12:53 AM, Steve Cronin <email@hidden> wrote:
> I realize the 'bad' nature of the calling code, I just want to
> understand what is going on that makes version 1 not see p1 as an
> equivalent string.  The compiler allows version 1 with no comment and
> at run time there is no type error when the message is passed.
>
> Clues? Links?

We can't help you unless you show us the actual code that is broken.

The code you pasted was obviously not the code that you tested. (A) It
won't compile -- missing '}'. (B) You use two constants -- @"xyz" and
@"xyx" -- which will always give a response of "No Match".

Bellow is my rewrite of your case, which works as expected. Your
problem is elsewhere.

#import <Foundation/Foundation.h>

@interface Foo : NSObject {}
- (void) test:(NSString*)aString;
@end

@implementation Foo
- (void) test:(NSString*)aString {
	if ([aString isEqualToString:@"xyz"])
		NSLog( @"MATCH: %@ == xyz", aString );
	else
		NSLog( @"NO MATCH: %@ != xyz", aString );
}
@end

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

	Foo *foo = [[[Foo alloc] init] autorelease];

	[foo test:@"xyx"];
	[foo test:@"xyz"];
	[foo test:[NSString stringWithString:@"xyx"]];
	[foo test:[NSString stringWithString:@"xyz"]];

    [pool release];
    return 0;
}
_______________________________________________

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

References: 
 >Why does [someObj msgA:@"xyx"] not give my expected result (From: Steve Cronin <email@hidden>)

  • Prev by Date: Why does [someObj msgA:@"xyx"] not give my expected result
  • Next by Date: Re: javascript ---> Cocoa
  • Previous by thread: Why does [someObj msgA:@"xyx"] not give my expected result
  • Next by thread: [OT] Chown returns file lock error
  • Index(es):
    • Date
    • Thread