views:

380

answers:

3

I'm getting this same error, but I've checked to make sure the properties were set correctly in the .h file.

Here's the code: NSUInteger theSizesCount = [theWho.theSizes count];

The error is "error: request for member theSizes in something not a strucutre or union. This .m file is importing 6 .h files, and 4 of them have the same properties in theWho, but it's related to various Super Classes. This .m file is implementing only one of them, and theWho and theSize are sythesized.

Also, in this code, and theSizes variable is green, but theWho variable is not. Plus, the error is happening in multiple places for NSUIntegers, NSMutableArray etc.

Where am I going wrong? Some of the header file code is below.


// TheSize.h

@class TheWho;

@interface TheSize :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *amount;
@property (nonatomic, retain) TheWho *theWho;
@property (nonatomic, retain) NSNumber *displayOrder;

@end

and..

//
// TheWho.h
//


@interface ImageToDataTransformer : NSValueTransformer {
}
@end


@interface TheWho : NSManagedObject {
}

@property (nonatomic, retain) NSString *instructions;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSSet *theSize;
@property (nonatomic, retain) UIImage *thumbnailImage;

@property (nonatomic, retain) NSManagedObject *image;
@property (nonatomic, retain) NSManagedObject *type;

@end


@interface TheWho (CoreDataGeneratedAccessors)
- (void)addTheSizesObject:(NSManagedObject *)value;
- (void)removeTheSizesObject:(NSManagedObject *)value;
- (void)addTheSizes:(NSSet *)value;
- (void)removeTheSizes:(NSSet *)value;
@end
A: 

You still need to define the member variables. The @property directive declares the accessor methods, not the underlying members.

@interface TheWho : NSManagedObject {
    NSString *instructions;
    NSString *name;
    NSSet *theSize;
    UIImage *thumbnailImage;

    NSManagedObject *image;
    NSManagedObject *type;
}
outis
False. The runtime on iPhone will `synthesize` the ivars. Also, the properties are dynamic when dealing with NSManagedObject subclasses, if I'm not mistaken.
jbrennan
A: 

You're trying to access theWho.theSizes but according to your header file, you should be trying theWho.theSize (without the trailing s).

Unless, there's a typo in how you've typed it here, and it wasn't copied directly.

jbrennan
Thanks. I tried it, and it generated more errors than before. I'm using the Core Data Recipes sample code as a guide, and it uses both the variable and the variable + training S.
+1  A: 

I checked my declarations again, and I had to add an "s" to the NSSet *theSize entry. Those errors are gone. Thanks all for the help.