• 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: (id) issue, passing different types during initWith:(id)type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (id) issue, passing different types during initWith:(id)type


  • Subject: Re: (id) issue, passing different types during initWith:(id)type
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 29 Jan 2011 08:56:29 -0800

On Sat, 29 Jan 2011 16:29:53 +0100, Travis Kirton <email@hidden> said:
>Hi,
>
>I am creating an aggregate object, for a project, with an initialization method:
>
>-(id)initWithString:(id)aString {
>	if(![super init]) {
>		return nil;
>	}
>	if([aString isKindOfClass:[NSString class]]) {
>		self.string = (NSString *)aString;
>		self.attributes = nil;
>	}
>	else if ([aString isKindOfClass:[CFAString class]]) {
>		self.string = ((CFAString *)aString).string;
>		self.attributes = ((CFAString *)aString).attributes;
>	}
>	else {
>		CFALog(@"Type is not CFAString or NSString");
>		return nil;
>	}
>	return self;
>}
>
>The function runs fine and executes for passing both an NSString and a CFAString object...
>I can pass any objective-c type without a warning, but when I pass my own object called CFAString (even though it is an NSObject), the following warning appears:
>
>warning: incompatible Objective-C types 'struct CFAString *', expected 'struct NSString *' when passing argument 1 of 'initWithString:' from distinct Objective-C type

The problem is that the name "initWithString:" is taken. Pick another name. m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________

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

  • Prev by Date: Re: Printing a View
  • Next by Date: Re: readInBackgroundAndNotify and rsync output
  • Previous by thread: Re: (id) issue, passing different types during initWith:(id)type
  • Next by thread: NSScrollView, centering document view?
  • Index(es):
    • Date
    • Thread