开发者

Declaring classes

开发者 https://www.devze.com 2023-03-13 22:38 出处:网络
I updated to n开发者_运维技巧ew Xcode 4.2 (for iOS 5), but now my project doesn\'t build anymore with the error: \"\'Category\' redeclared as different symbol\". Then there is a host of errors related

I updated to n开发者_运维技巧ew Xcode 4.2 (for iOS 5), but now my project doesn't build anymore with the error: "'Category' redeclared as different symbol". Then there is a host of errors related as 'Request for member 'name' is not a structure or union and warnings like "Invalid receiver type 'Category'".

I guess it has to do with how I do my declarations. Regarding this (Core Data) class, I have the following declaration:

#import <CoreData/CoreData.h>

@class Article;
@interface Category :  NSManagedObject  
{
}

@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * desc;
@property (nonatomic, retain) NSDate * lastUpdate;
@property (nonatomic, retain) NSSet* articles;   
@end

@interface Category (CoreDataGeneratedAccessors)
- (void)addArticlesObject:(Article *)value;
- (void)removeArticlesObject:(Article *)value;
- (void)addArticles:(NSSet *)value;
- (void)removeArticles:(NSSet *)value;

@end

--

#import "Category.h"

@implementation Category 

@dynamic id;
@dynamic name;
@dynamic desc;
@dynamic lastUpdate;
@dynamic articles;

@end

--

In another Core Data class, which has a n:n relation I use "@class Category;" to declare. In the class where I use this class I import the header file: #import "Category.h".

What is the best way of doing this, or what more info there is needed to find the problem. I have tried all kinds of different combinations but am confused now when and how to declare. (the code worked fine the last time I build)


Your code is probably seeing things declaration from objc/runtime.h:

typedef struct objc_category *Category;

By convention, Cocoa classes are named with a two- or three-letter prefix indicating the originating person, organization or project. This helps avoid this kind of issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号