Domanda

I have one very strange problem.

I create object DimensionItem :

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Dimension;

@interface DimensionItem : NSManagedObject

@property (nonatomic, retain) NSNumber * dimItemID;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) Dimension *dimension;

@end

In some classes I can normaly access property ouf of it, but in some object when I create

DimensionItem * item = ...
item.name ---->  Property 'name' not found on object  of type 'DimensionItem'

I can't access to it and even autocorrect is off.

I include header in object :

#import "DimensionItem.h"

EDIT :

There was request for initialization code :

DimensionItem * item = [cubeItem getDimensionItemWhitDimensionID:self.dimensionID andDimensionItemID:[obj1 dimensionItemIndex]];

cubeitem is another NSManagedObject created which core data which has one-to-many relations with Dimension which has one-to-many relations with DimensionItem.

Function calculate position in set and return DimensionItem.

As I said, in some object this same function work with

item.name

but others don't

È stato utile?

Soluzione

You can't access the properties of a NSManagedObject like that, it's not like a normal object. This is because the access to those properties should be managed by CoreData, not by you.

You need to use:

//Set
[item setValue:@"myName" forKey:@"name"];

//Get
[item valueForKey:@"name"]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top