Skip navigation.
 
mlRe: warning: assignment from distinct Objective-C type
FROM : Quincey Morris
DATE : Tue Mar 11 23:49:34 2008

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.

Related mailsAuthorDate
mlwarning: assignment from distinct Objective-C type Stuart Malin Mar 11, 09:19
mlRe: warning: assignment from distinct Objective-C type Ron Fleckner Mar 11, 09:42
mlRe: warning: assignment from distinct Objective-C type Stuart Malin Mar 11, 09:50
mlRe: warning: assignment from distinct Objective-C type Julien Jalon Mar 11, 10:16
mlRe: warning: assignment from distinct Objective-C type Keary Suska Mar 11, 16:57
mlRe: warning: assignment from distinct Objective-C type Stuart Malin Mar 11, 19:03
mlRe: warning: assignment from distinct Objective-C type Julien Jalon Mar 11, 20:48
mlRe: warning: assignment from distinct Objective-C type Chris Hanson Mar 11, 21:42
mlRe: warning: assignment from distinct Objective-C type Stuart Malin Mar 11, 22:09
mlRe: warning: assignment from distinct Objective-C type Mike Abdullah Mar 11, 22:58
mlRe: warning: assignment from distinct Objective-C type Stuart Malin Mar 11, 23:49
mlRe: warning: assignment from distinct Objective-C type Quincey Morris Mar 11, 23:49
mlRe: warning: assignment from distinct Objective-C type j o a r Mar 11, 23:59
mlRe: warning: assignment from distinct Objective-C type mmalc crawford Mar 12, 01:56
mlRe: warning: assignment from distinct Objective-C type Quincey Morris Mar 12, 02:11
mlRe: warning: assignment from distinct Objective-C type mmalc crawford Mar 12, 06:39
mlRe: warning: assignment from distinct Objective-C type Dennis C. De Mars Mar 12, 17:26
mlRe: warning: assignment from distinct Objective-C type Keith Duncan Mar 12, 23:33