Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic message typing problem



Thanks to all who replied to my pleas for help.
I took Bill and Scott's suggestions to heart and produced the answer I needed: Dynamic Typing which allows me to avoid circularity etc.


I post the complete solution as an example and to check that I'm not running close to the wind by using a dummy class definition. The code gets no compiler warnings.

//  AnonTargetClass.h
#import <Cocoa/Cocoa.h>
@interface AnonTargetClass : NSObject {
}
- (void) printFloat:(float)pF;

//  AnonTargetClass.m
#import "AnonTargetClass.h"
@implementation AnonTargetClass
- (void) printFloat:(float)pF {
	NSLog(@"%7.3f",pF);
}

//  DummyClass.h
#import <Cocoa/Cocoa.h>
@interface DummyClass : NSObject {
}
- (void) printFloat:(float)pF;

//  DummyClass.m
#import "DummyClass.h"
@implementation DummyClass
- (void) printFloat:(float)pF {
}

//  CallingClass.h
#import <Cocoa/Cocoa.h>
#import "DummyClass.h";
@interface CallingClass : NSObject {
}
- (void) callPrintConstFloat:(id)pId;
- (void) callPrint:(id)pId zFloat:(float)pF;

//  CallingClass.m
#import "CallingClass.h"
@implementation CallingClass
- (void) callPrintConstFloat:(id)pId {
	[pId printFloat:99.99];
}
- (void) callPrint:(id)pId zFloat:(float)pF {
	[pId printFloat:pF];
}

//  main.m
#import <Cocoa/Cocoa.h>
#import "AnonTargetClass.h"
#import "CallingClass.h"

int main(int argc, char *argv[])
{
	AnonTargetClass 	* atcObj		= [[AnonTargetClass alloc]init];
	CallingClass			* callingObj	= [[CallingClass alloc]init];
	
	[callingObj callPrintConstFloat:atcObj];	
	[atcObj printFloat:88.88];
}


[Session started at 2008-05-17 00:33:01 +0100.] 2008-05-17 00:33:01.988 testDynamicBinding[2436:10b] 99.990 2008-05-17 00:33:01.989 testDynamicBinding[2436:10b] 88.880

Thanks again
Julius

http://juliuspaintings.co.uk



_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.