• 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: warning: assignment from distinct Objective-C type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning: assignment from distinct Objective-C type


  • Subject: Re: warning: assignment from distinct Objective-C type
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 11 Mar 2008 15:49:34 -0700


On Mar 11, 2008, at 14:09, Stuart Malin wrote:

My rationale for departing from the canonical approach is because then I get a bit of extra type checking at compile time.

Personally I prefer the factory method approach, a la [NSArray array] etc:


In your header file:

	+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate;

In the implementation:

- (id) initWithDelegate:(id)initialDelegate {...}
+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate {return [[[XMPPStream alloc] initWithDelegate:initialDelegate] autorelease];}


Usage:

	someStream = [XMPPStream xmppStreamWithDelegate:delegate];

This (a) gives you the compile time type check, (b) saves a few keystrokes of clutter wherever you actually create one of these, (c) forces creation of the object to use a designated initializer without chance of mistakes, and (d) allows you to use the proper (id) return type on your initializers.


_______________________________________________

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: warning: assignment from distinct Objective-C type
      • From: j o a r <email@hidden>
References: 
 >warning: assignment from distinct Objective-C type (From: Stuart Malin <email@hidden>)
 >Re: warning: assignment from distinct Objective-C type (From: Chris Hanson <email@hidden>)
 >Re: warning: assignment from distinct Objective-C type (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: warning: assignment from distinct Objective-C type
  • Next by Date: Re: warning: assignment from distinct Objective-C type
  • Previous by thread: Re: warning: assignment from distinct Objective-C type
  • Next by thread: Re: warning: assignment from distinct Objective-C type
  • Index(es):
    • Date
    • Thread