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

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


  • Subject: (id) issue, passing different types during initWith:(id)type
  • From: Travis Kirton <email@hidden>
  • Date: Sat, 29 Jan 2011 16:29:53 +0100

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

I would like to know how to fix my code, or another approach, so that this warning doesn't appear...


_______________________________________________

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

  • Follow-Ups:
    • Re: (id) issue, passing different types during initWith:(id)type
      • From: Quincey Morris <email@hidden>
    • Re: (id) issue, passing different types during initWith:(id)type
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: readInBackgroundAndNotify and rsync output
  • Next by Date: Re: readInBackgroundAndNotify and rsync output
  • Previous by thread: Re: Initializing NSWindow with Carbon window
  • Next by thread: Re: (id) issue, passing different types during initWith:(id)type
  • Index(es):
    • Date
    • Thread