0

私は xCode が初めてで、自分が書いていないコードを操作しようとしています。これがばかげた質問である場合は申し訳ありません!

コードを実行した後、ここにエンティティを作成します (エンティティは Entities.h によって定義されます)。

Entities *proxy = [[Entities alloc]initWithUri:@"http://localhost:8080/Resource/example.svc" credential:nil];
DataServiceQuery *qry = [proxy person];
QueryOperationResponse *result = [qry execute];
items = [result getResult];
NSLog(@"items size: %@", items);

これはうまく機能し、次のように出力されます。

ここに画像の説明を入力

ただし、Model_person の変数にアクセスする方法がわかりません。

Entities.h の関連コードは次のとおりです。

/**
* @interface:person
* @Type:EntityType

* @key:person_id* 
*/
@interface Model_person : ODataObject
{

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_id;

/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_role;

/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_firstname;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_department;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_contractor;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_supervisor;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_admin;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_workweek;

/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_employee_id;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_billrate;

/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_lastname;

/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_active;

}


@property ( nonatomic , retain , getter=getperson_id , setter=setperson_id : )NSNumber   *m_person_id;
@property ( nonatomic , retain , getter=getperson_role , setter=setperson_role : ) NSString *m_person_role;
@property ( nonatomic , retain , getter=getperson_firstname , setter=setperson_firstname : ) NSString *m_person_firstname;
@property ( nonatomic , retain , getter=getperson_department , setter=setperson_department : )NSNumber *m_person_department;
@property ( nonatomic , retain , getter=getperson_contractor , setter=setperson_contractor : )NSNumber *m_person_contractor;
@property ( nonatomic , retain , getter=getperson_supervisor , setter=setperson_supervisor : )NSNumber *m_person_supervisor;
@property ( nonatomic , retain , getter=getperson_admin , setter=setperson_admin : )NSNumber *m_person_admin;
@property ( nonatomic , retain , getter=getperson_workweek , setter=setperson_workweek : )NSNumber *m_person_workweek;
@property ( nonatomic , retain , getter=getperson_employee_id , setter=setperson_employee_id : ) NSString *m_person_employee_id;
@property ( nonatomic , retain , getter=getperson_billrate , setter=setperson_billrate : )NSNumber *m_person_billrate;
@property ( nonatomic , retain , getter=getperson_lastname , setter=setperson_lastname : ) NSString *m_person_lastname;
@property ( nonatomic , retain , getter=getperson_active , setter=setperson_active : )NSNumber *m_person_active;

+ (id) Createperson;
- (id) init;
- (id) initWithUri:(NSString*)anUri;
@end

注: 次の方法で cellForRowAtIndexPath の要素にアクセスしようとしました。

Entities *event = [items objectAtIndex:indexPath.row];
cell.textLabel.text = [[[event getperson] objectAtIndex: 0] getName];

そして、「'DataServiceQuery' の目に見える @interface がセレクター 'ObjectAtIndex' を宣言していません」というエラーをスローしました。

アップデート:

getperson は Entities.h でも定義されています。

/**
* Container interface Entities, Namespace: Model
*/
@interface Entities : ObjectContext
{
 NSString *m_OData_etag;

    DataServiceQuery *m_member;

    DataServiceQuery *m_cumulative;

    DataServiceQuery *m_date;

    DataServiceQuery *m_holiday;

    DataServiceQuery *m_associations;

    DataServiceQuery *m_department;

    DataServiceQuery *m_person;

    DataServiceQuery *m_project;

}

@property ( nonatomic , retain , getter=getEtag , setter=setEtag : )NSString *m_OData_etag;

@property ( nonatomic , retain , getter=getmember , setter=setmember : ) DataServiceQuery *m_member;

@property ( nonatomic , retain , getter=getcumulative , setter=setcumulative : ) DataServiceQuery *m_cumulative;

@property ( nonatomic , retain , getter=getdate , setter=setdate : ) DataServiceQuery *m_date;

@property ( nonatomic , retain , getter=getholiday , setter=setholiday : ) DataServiceQuery *m_holiday;

@property ( nonatomic , retain , getter=getassociations , setter=setassociations : ) DataServiceQuery *m_associations;

@property ( nonatomic , retain , getter=getdepartment , setter=setdepartment : ) DataServiceQuery *m_department;

@property ( nonatomic , retain , getter=getperson , setter=setperson : ) DataServiceQuery *m_person;

@property ( nonatomic , retain , getter=getproject , setter=setproject : ) DataServiceQuery *m_project;

- (id) init;
- (id) initWithUri:(NSString*)anUri credential:(id)acredential;
- (id) member;
- (id) cumulative;
- (id) date;
- (id) holiday;
- (id) associations;
- (id) department;
- (id) person;
- (id) project;
- (void) addTomember:(id)anObject;
- (void) addTocumulative:(id)anObject;
- (void) addTodate:(id)anObject;
- (void) addToholiday:(id)anObject;
- (void) addToassociations:(id)anObject;
- (void) addTodepartment:(id)anObject;
- (void) addToperson:(id)anObject;
- (void) addToproject:(id)anObject;

@end
4

1 に答える 1

1

次のように書くべきだと思います。

Model_person* modelPerson = [items objectAtIndex:indexPath.row];
cell.textLabel.text = modelPerson.getperson_firstname;

それ以外の

Entities *event = [items objectAtIndex:indexPath.row];
cell.textLabel.text = [[[event getperson] objectAtIndex: 0] getName];
于 2013-07-10T17:58:59.540 に答える