| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
28: - (KCLine *)getLineWithColor:(KCColor *)color
29: {
30: if(linesByColor == nil)
31: linesByColor = [[[NSMutableDictionary alloc] init] autorelease];
32:
33: KCLine *line = [linesByColor objectForKey:color];
34: if(line == nil)
35: {
36: line = [[KCLine alloc] init];
37: [linesByColor setObject:line forKey:color];
38: NSLog(@"Creating %@ line\n", color);
39: }
40: return line;
41: }
/Users/ryan/Downloads/QuartzLines/KCLineFactory.m:36: warning: receiver 'KCLine' is a forward class and corresponding @interface may not exist
Users/ryan/Downloads/QuartzLines/KCLineFactory.m:37: warning: 'NSDictionary' may not respond to '-setObject:forKey:'
I've lookup up the "forward class..." error and it seems this is caused by @class KCLine; Does anyone ever use the old C trick for Obj-C header files ?
#ifndef _STDIO_H_
#define _STDIO_H_
/* contents of stdio.h */
Thanks alot everyone! @class worked. KCLineFactory.h ended up looking like:#import <Cocoa/Cocoa.h>
@class KCLine;
@class KCColor;
@interface KCLineFactory : NSObject
{
NSDictionary *linesByColor;
}
+ (KCLineFactory *)sharedKCLineFactory;
- (KCLine *)getLineWithColor:(KCColor *)color;
@end
On Sat, Apr 26, 2008 at 8:05 AM, Jean-Claude Turcq <email@hidden> wrote:usually when you implemented your own objects like :@interface MyOwnObject{MyOwnSecondObject *lpSO;}@endyou need to tell the compiler that MyOwnSecondObject is a class you implemented yourself with the following line before the interface:@class MyOwnSecondObject; //to specify you implements elsewhere@interface MyOwnObject{MyOwnSecondObject *lpSO;}@endso in your example, why not trying declare before your interface :@class KCLine;@class KCLineFactory;@class KCColor;what's the result ???Le 26 avr. 08 à 00:56, Ryan Chapman a écrit :
I'm sure this is simple, but I'm new to Obj-C, so I can't figure it out.I've modified the QuartzLines Cocoa project to test drawing lines as flyweights. I've created a singleton factory called KCLineFactory that stores an NSMutableDictionary of KCLine objectsI'm getting the following compiler error:/Users/ryan/Downloads/QuartzLines/KCLineFactory.h:20: error: syntax error before 'KCLine'
and here is KCLineFactory.h:1: //2: // LineFactory.h3: // QuartzLines4: //5: // Created by Ryan on 4/24/08.6: // Copyright 2008 Initech, Inc.. All rights reserved.7: //8:9: #import <Cocoa/Cocoa.h>10: #import "KCLine.h"11: #import "KCColor.h"12:13: @interface KCLineFactory : NSObject14: {15: NSDictionary *linesByColor;16: }17:18: + (KCLineFactory *)sharedKCLineFactory;19:20: - (KCLine *)getLineWithColor:(KCColor *)color;21:22: @end
KCLine and KCColor are objects defined in KCLine.m and KCColor.mWhere is the syntax error?Thanks_______________________________________________http://lists.apple.com/mailman/options/objc-language/email@hidden
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden This email sent to email@hidden
| References: | |
| >Syntax error in header file (From: "Ryan Chapman" <email@hidden>) | |
| >Re: Syntax error in header file (From: Jean-Claude Turcq <email@hidden>) | |
| >Re: Syntax error in header file (From: "Ryan Chapman" <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.